public ActionResult Create(questions questions)
        {
            if (ModelState.IsValid)
            {
                context.questions.AddObject(questions);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(questions);
        }
Beispiel #2
0
        public ActionResult Create(questions questions)
        {
            if (ModelState.IsValid)
            {
                db.questions.AddObject(questions);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.EventID = new SelectList(db.events, "EventID", "Title", questions.EventID);
            ViewBag.StudentID = new SelectList(db.students, "StudentID", "NickName", questions.StudentID);
            return View(questions);
        }
Beispiel #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the questions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToquestions(questions questions)
 {
     base.AddObject("questions", questions);
 }
Beispiel #4
0
 /// <summary>
 /// Create a new questions object.
 /// </summary>
 /// <param name="questionID">Initial value of the QuestionID property.</param>
 public static questions Createquestions(global::System.Int32 questionID)
 {
     questions questions = new questions();
     questions.QuestionID = questionID;
     return questions;
 }
Beispiel #5
0
 public ActionResult Edit(questions questions)
 {
     if (ModelState.IsValid)
     {
         db.questions.Attach(questions);
         db.ObjectStateManager.ChangeObjectState(questions, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.EventID = new SelectList(db.events, "EventID", "Title", questions.EventID);
     ViewBag.StudentID = new SelectList(db.students, "StudentID", "NickName", questions.StudentID);
     return View(questions);
 }
        public ActionResult Edit(questions questions, FormCollection collection)
        {
            var answerContent = collection["AnswerContent"];

            if (ModelState.IsValid)
            {
                //create new answer
                asnwers answer = new asnwers();
                answer.CreatedDate = DateTime.UtcNow;
                answer.Content = answerContent;
                answer.LecturerID = context.lecturers.Single(x => x.UserName == User.Identity.Name).LecturerID;
                context.asnwers.AddObject(answer);
                context.SaveChanges();

                questions.AnswerID = answer.AsnwerID;

                context.questions.Attach(questions);
                //questions _question = context.questions.Single(x => x.QuestionID == questions.QuestionID);

                context.ObjectStateManager.ChangeObjectState(questions, EntityState.Modified);
                context.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(questions);
        }
 public void Delete(questions entity)
 {
     Repository.Delete(entity);
 }
 public void Add(questions entity)
 {
     Repository.Add(entity);
 }