public ActionResult Create(Routine routine) { if (ModelState.IsValid) { db.Routines.Add(routine); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UserId = new SelectList(db.Users, "UserId", "Email", routine.UserId); ViewBag.TypeId = new SelectList(db.Types, "TypeId", "Name", routine.TypeId); return View(routine); }
public ActionResult Edit(Routine routine) { if (ModelState.IsValid) { db.Entry(routine).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UserId = new SelectList(db.Users, "UserId", "Email", routine.UserId); ViewBag.TypeId = new SelectList(db.Types, "TypeId", "Name", routine.TypeId); return View(routine); }