public ActionResult UpdateSupplier(SupplierPO form) { ActionResult response; if (ModelState.IsValid) { try { //Map given info to DO. SupplierDO supplierDO = SupplierMapper.PoToDo(form); //Update supplier in SQL giving DO info. _SupplierDAO.UpdateSupplier(supplierDO); //Return to view all suppliers page. response = RedirectToAction("Index", "Supplier"); } catch (SqlException sqlex) { response = RedirectToAction("Error", "Shared"); } catch (Exception ex) { response = RedirectToAction("Error", "Shared"); Logger.ErrorLogPath = _LogPath; Logger.ExceptionLog(ex); } } else { response = View(); } return(response); }
public ActionResult CreateSupplier(SupplierPO form) { ActionResult response; //Check if valid info was given, Back to create supplier view page if not. if (ModelState.IsValid) { try { //Map given info to DO. SupplierDO newSupplier = SupplierMapper.PoToDo(form); //Create supplier in SQL, giving DO info. _SupplierDAO.CreateSupplier(newSupplier); //Return to view all supplier page. response = RedirectToAction("Index", "Supplier"); } catch (SqlException sqlex) { response = RedirectToAction("Error", "Shared"); } catch (Exception ex) { response = RedirectToAction("Error", "Shared"); Logger.ErrorLogPath = _LogPath; Logger.ExceptionLog(ex); } } else { response = View(); } return(response); }