public ActionResult Create(Section section) { if (ModelState.IsValid) { db.Sections.Add(section); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Code", section.DepartmentId); return View(section); }
public ActionResult Edit(Section section) { if (ModelState.IsValid) { db.Entry(section).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Code", section.DepartmentId); return View(section); }