public ActionResult Create(Server server) { if (ModelState.IsValid) { db.Servers.Add(server); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.InfrastructureID = new SelectList(db.Infrastructures, "InfrastructureID", "InfrastructureName", server.InfrastructureID); ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", server.DepartmentID); return View(server); }
public ActionResult Edit(Server server) { if (ModelState.IsValid) { db.Entry(server).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.InfrastructureID = new SelectList(db.Infrastructures, "InfrastructureID", "InfrastructureName", server.InfrastructureID); ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", server.DepartmentID); return View(server); }