public ActionResult Create(Service service) { if (ModelState.IsValid) { db.Services.Add(service); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", service.DepartmentID); ViewBag.ServerID = new SelectList(db.Servers, "ServerID", "ServerName", service.ServerID); return View(service); }
public ActionResult Edit(Service service) { if (ModelState.IsValid) { db.Entry(service).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", service.DepartmentID); ViewBag.ServerID = new SelectList(db.Servers, "ServerID", "ServerName", service.ServerID); return View(service); }