public ActionResult UpdateProducer(long ProducerID) { ProducerVM updateVM = new ProducerVM(); IProducerInfoDO producer = _ProducerAccess.ViewProducerByID(ProducerID); updateVM.Producer = ProducerMap.MapDOtoPO(producer); return(View(updateVM)); }
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)); }
private SelectList PopulateProducersDDL() { //for entereing shipments, need to know it is coming from a farmer in the db! List <IProducerInfoDO> databaseProducers = _ProducerAccess.ViewAllProducers(); //map List <ProducerPO> mappedProducers = ProducerMap.MapDOtoPO(databaseProducers); List <ProducerPO> actualList = new List <ProducerPO>(); //add dummy location for "default" on dropdown, otherwise it sets to ACTUAL location actualList.Add(new ProducerPO() { ProducerID = 0, CompanyName = " -- Please choose a Producer --" }); //after dummy is in top stop, add range from db actualList.AddRange(mappedProducers); //producer id what is listed, user will see label as Company Name return(new SelectList(actualList, "ProducerID", "CompanyName")); }