private void DropDown() { // create a new list ViewBag.ListSuppliers = new List <SelectListItem>(); // call the method and map info to the list List <SupplierPO> supplier = _mapper.Map(_supplierDataAccess.ViewAllSuppliers()); // create a foreach loop to loop through the avaiable suppliers foreach (SupplierPO suppliers in supplier) { ViewBag.ListSuppliers.Add(new SelectListItem { Text = suppliers.supplierName, Value = suppliers.supplierID.ToString() }); } }
public ActionResult ViewSuppliers() { if ((string)Session["roleName"] == "admin" || (string)Session["roleName"] == "moderator") { // create a new instance of supplerViewModel SupplierViewModel _supplierViewModel = new SupplierViewModel(); // call the view suppliers method pass it through the dataAccess and mapper // then set it to the supplier list _supplierViewModel.listSupplierPO = _mapper.Map(_supplierDataAccess.ViewAllSuppliers()); // return the view return(View(_supplierViewModel)); } return(RedirectToAction("ViewProducts")); }