Exemple #1
0
        // create the mappers for each object
        // create the mapper for a list of products
        //sdf
        public List <ProductPO> Map(List <ProductDAO> productListToMap)
        {
            // create a new instance of the list
            List <ProductPO> productListToReturn = new List <ProductPO>();

            // create a foreach loop to run through the whole list
            foreach (ProductDAO productToMap in productListToMap)
            {
                // create a new instance of productPO
                ProductPO productToView = new ProductPO();

                // get the values from each element
                productToView.productID              = productToMap.productID;
                productToView.supplierID             = productToMap.supplierID;
                productToView.supplierName           = productToMap.supplierName;
                productToView.productDescription     = productToMap.productDescription;
                productToView.productProcessor       = productToMap.productProcessor;
                productToView.productOperatingSystem = productToMap.productOperatingSystem;
                productToView.productQuantity        = productToMap.productQuantity;
                productToView.productRam             = productToMap.productRam;
                productToView.productPrice           = productToMap.productPrice;

                productListToReturn.Add(productToView);
            }
            // return the finally list of all products
            return(productListToReturn);
        }
Exemple #2
0
        // create a mapper to go from the db to the view
        public ProductDAO Map(ProductPO productToMap)
        {
            // create a new instance of productDAO to go from db to view
            ProductDAO productToView = new ProductDAO();

            // map the values
            productToView.productID              = productToMap.productID;
            productToView.supplierID             = productToMap.supplierID;
            productToView.supplierName           = productToMap.supplierName;
            productToView.productDescription     = productToMap.productDescription;
            productToView.productProcessor       = productToMap.productProcessor;
            productToView.productOperatingSystem = productToMap.productOperatingSystem;
            productToView.productQuantity        = productToMap.productQuantity;
            productToView.productRam             = productToMap.productRam;
            productToView.productPrice           = productToMap.productPrice;


            // return the product
            return(productToView);
        }
 // create the method for the productViewModel
 public ProductViewModel()
 {
     // instaniate a new instance of the single product and list of products
     singleProductPO = new ProductPO();
     listProductPO   = new List <ProductPO>();
 }