public ActionResult Edit(Priority priority) { if (ModelState.IsValid) { unitofWork.PriorityRepository.InsertOrUpdate(priority); unitofWork.Save(); return RedirectToAction("Index"); } return View(priority); }
public void InsertOrUpdate(Priority priority) { if (priority.PriorityID == default(int)) { // New entity context.Priorities.Add(priority); } else { // Existing entity context.Entry(priority).State = System.Data.Entity.EntityState.Modified; } }