public ActionResult Create(Comment comment) { if (ModelState.IsValid) { db.Comments.Add(comment); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.memberID = new SelectList(db.Members, "ID", "loginID", comment.memberID); ViewBag.mpID = new SelectList(db.MPs, "ID", "firstName", comment.mpID); ViewBag.sectorID = new SelectList(db.Sectors, "ID", "title", comment.sectorID); return View(comment); }
public ActionResult Edit(Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.memberID = new SelectList(db.Members, "ID", "loginID", comment.memberID); ViewBag.mpID = new SelectList(db.MPs, "ID", "firstName", comment.mpID); ViewBag.sectorID = new SelectList(db.Sectors, "ID", "title", comment.sectorID); return View(comment); }