public ActionResult Create(Department department) { if (ModelState.IsValid) { db.DepartmentDbSet.Add(department); if (db.SaveChanges() > 0) ViewBag.Message = "Department :- " + department.DeptCode + " has been saved successfully ."; return View(department); } return View(department); }
public ActionResult Edit(Department department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(department); }