public ActionResult ViewShipments() { ActionResult oResponse = null; ShipmentVM newVM = new ShipmentVM(); if (Session["UserName"] != null && ((int)Session["UserLevel"] == 2 || (int)Session["UserLevel"] == 1)) { try { //call to db to obtain all shipments, then map list data to presentation list obj. List <IShipmentInfoDO> shipmentData = _ShipmentAccess.ViewAllShipments(); newVM.ShipmentList = ShipmentMap.MapDOtoPO(shipmentData); } catch (Exception) { newVM.ErrorMessage = "There was an issue obtaining the list"; } finally { oResponse = View(newVM); } } else { oResponse = RedirectToAction("Login", "User"); } return(oResponse); }
public ActionResult ViewProducers() { //instantiate new viewmodel obj. ProducerVM newVM = new ProducerVM(); //make sure user is authorized to add producer if (Session["UserName"] == null || (int)Session["UserLevel"] == 3) { RedirectToAction("Login", "User"); } else { //instantiated new viewmodel, fill below try { //call to DAL for method, reader fills list in method List <IProducerInfoDO> ProducerData = _ProducerAccess.ViewAllProducers(); //call to method from mapping class newVM.ProducerList = ProducerMap.MapDOtoPO(ProducerData); //get a fresh list of shipments List <IShipmentInfoDO> mylist = _ShipmentAccess.ViewAllShipments(); //Map each from DO to a BO List <IShipmentInfoBO> viewTop = ShipmentMap.MapDOtoBO(mylist); //call to the business logic, pass the information. long topProducerID = _ShipmentLogic.GetTopProducer(viewTop); //turn id into an object by calling down to the database, map in line. newVM.Producer = ProducerMap.MapDOtoPO(_ProducerAccess.ViewProducerByID(topProducerID)); //now top producer is in PO form, can display using producerVM } catch (Exception) { newVM.ErrorMessage = "There was an issue obtaining the list"; } finally { ///nothing else needs to happen } } return(View(newVM)); }