public ActionResult Edit(int?productID) { try { if (productID != null) { var product_Edited = SelectProductByID(Convert.ToInt32(productID)); if (product_Edited != null) { var viewModel = new Suppliers_Product() { Product = product_Edited, Suppliers = product.LoadAllSuppliers() }; return(View(viewModel)); } else { throw new Exception("There is a problem when loading this Produt try again later"); } } else { throw new Exception("There is a Problem there is no such Product"); } }catch (Exception ex) { ExceptionHandler.LogException(ex, "Product_MVC_Edit_action_method"); ViewBag.Message = Server.HtmlEncode(ex.Message); return(View("Error")); } }
public ActionResult Edit(Suppliers_Product viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } try { UpdateProduct(viewModel.Product); return(RedirectToAction("Index")); }catch (Exception ex) { ExceptionHandler.LogException(ex, "Product_MVC_Edit_action_method"); ViewBag.Message = Server.HtmlEncode(ex.Message); return(View("Error")); } }