public ActionResult Edit(Product product) { try { Repository.Save(product); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(Product product) { try { var existingProduct = DB.Products.Single(p => p.ProductID == product.ProductID); existingProduct.Name = product.Name; existingProduct.ProductNumber = product.ProductNumber; existingProduct.ListPrice = product.ListPrice; DB.SubmitChanges(); return RedirectToAction("Index"); } catch { return View(); } }