// create a mapper method that goes from the view to db for the suppliers public SupplierPO Map(SupplierDAO supplierToMap) { // create a new instance ofsupplierDAO SupplierPO supplierToView = new SupplierPO(); // map the values for the supplier supplierToView.supplierID = supplierToMap.supplierID; supplierToView.supplierName = supplierToMap.supplierName; supplierToView.supplierAddress = supplierToMap.supplierAddress; supplierToView.supplierCity = supplierToMap.supplierCity; supplierToView.supplierState = supplierToMap.supplierState; supplierToView.supplierZip = supplierToMap.supplierZip; supplierToView.supplierPhoneNumber = supplierToMap.supplierPhoneNumber; // return the supplier return(supplierToView); }
// create a mapper to list all of the suppliers public List <SupplierPO> Map(List <SupplierDAO> supplierListToMap) { // create a new insatance of the supplierPO list List <SupplierPO> supplierListToReturn = new List <SupplierPO>(); // create a foreach loop to loop through the whole list foreach (SupplierDAO supplierToMap in supplierListToMap) { // create a new instance of supplierPO SupplierPO supplierToView = new SupplierPO(); // map the values supplierToView.supplierID = supplierToMap.supplierID; supplierToView.supplierName = supplierToMap.supplierName; supplierToView.supplierAddress = supplierToMap.supplierAddress; supplierToView.supplierCity = supplierToMap.supplierCity; supplierToView.supplierState = supplierToMap.supplierState; supplierToView.supplierZip = supplierToMap.supplierZip; supplierToView.supplierPhoneNumber = supplierToMap.supplierPhoneNumber; supplierListToReturn.Add(supplierToView); } // return the list of suppliers return(supplierListToReturn); }
// create the method for the SupplierViewModel public SupplierViewModel() { // instaniate a new instance of the single supplier and list of suppliers singleSupplierPO = new SupplierPO(); listSupplierPO = new List <SupplierPO>(); }