public ActionResult Edit(Customer customer) { if (ModelState.IsValid) { customerRepository.InsertOrUpdate(customer); customerRepository.Save(); return RedirectToAction("Index"); } return View(); }
public void InsertOrUpdate(Customer customer) { if (customer.ID == default(int)) { context.Customers.Add(customer); } else { context.Entry(customer).State = EntityState.Modified; } }