public ActionResult Edit(Product product) { try { Repository.Save(product); return RedirectToAction("Index"); } catch { return View(product); } }
public Product Save(Product product) { if (product.ProductID > 0) { var existingProduct = Get().Single(p => p.ProductID == product.ProductID); existingProduct.Name = product.Name; existingProduct.ProductNumber = product.ProductNumber; existingProduct.ListPrice = product.ListPrice; product = existingProduct; } else { DB.Products.InsertOnSubmit(product); } DB.SubmitChanges(); return product; }
partial void DeleteProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void InsertProduct(Product instance);