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); }
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); }