public ActionResult UpdateSupplier(int supplierId) { ActionResult response; if (ModelState.IsValid) { try { //Obtain supplier info from SQL using given ID. SupplierDO supplierDO = _SupplierDAO.ObtainSupplierById(supplierId); //Map DO to PO. SupplierPO supplier = SupplierMapper.DoToPo(supplierDO); //Give view page with obtained info. response = View(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 ViewSupplierDetails(int supplierId) { ActionResult response; if (ModelState.IsValid) { try { SupplierVM supplierDetails = new SupplierVM(); //Getting specific supplier info from SQL with ID and storing it into SupplierViewModel. supplierDetails.SupplierData = SupplierMapper.DoToPo(_SupplierDAO.ObtainSupplierById(supplierId)); //Getting all products supplied by specific supplier ID and storing it into SupplierViewModel. supplierDetails.ProductsBySupplier = ProductMapper.DOToPO(_ProductDAO.ObtainProductsBySupplierID(supplierId)); //View supplier details. response = View(supplierDetails); } catch (SqlException sqlex) { response = View("Error"); } catch (Exception ex) { response = View("Error"); Logger.ErrorLogPath = _LogPath; Logger.ExceptionLog(ex); } } else { response = View(); } return(response); }