コード例 #1
0
 public ActionResult Edit(AnswerChoice answerchoice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(answerchoice).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "QuestionText", answerchoice.QuestionId);
     return View(answerchoice);
 }
コード例 #2
0
        public ActionResult Create(AnswerChoice answerchoice)
        {
            if (ModelState.IsValid)
            {
                db.AnswerChoices.Add(answerchoice);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }

            ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "QuestionText", answerchoice.QuestionId);
            return View(answerchoice);
        }