public ActionResult Edit(int id, IFormCollection collection) { try { var c = GetCustomerById(id); c.Name = collection["Name"]; TryValidateModel(c); _context.Update(c); _context.SaveChanges(); return(RedirectToAction(nameof(List))); } catch { return(View()); } }
public ActionResult Edit(int id, IFormCollection collection) { try { var s = GetServiceById(id); s.Name = collection["Name"]; s.Cost = System.Convert.ToInt32(collection["Cost"]); TryValidateModel(s); _context.Update(s); _context.SaveChanges(); return(RedirectToAction(nameof(List))); } catch { return(View()); } }