public ActionResult Edit(Message message) { if (ModelState.IsValid) { db.Entry(message).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Sender = new SelectList(db.Users, "UserID", "LastName", message.Sender); ViewBag.Recepient = new SelectList(db.Users, "UserID", "LastName", message.Recepient); return View(message); }
public ActionResult Create(Message message) { if (ModelState.IsValid) { db.Messages.Add(message); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Sender = new SelectList(db.Users, "UserID", "LastName", message.Sender); ViewBag.Recepient = new SelectList(db.Users, "UserID", "LastName", message.Recepient); return View(message); }