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

            ViewBag.QuestionId = new SelectList(db.Questions, "Id", "Text", answer.QuestionId);
            return View(answer);
        }