Beispiel #1
0
 public static ProductVM GetProduct(int id)
 {
     ProductMapper productMapper = new ProductMapper();
        Product returnedProduct =  productMapper.GetProduct(id);
        ProductVM newProductVm = new ProductVM(returnedProduct.Id,returnedProduct.Name, returnedProduct.Category,  returnedProduct.Color,
        returnedProduct.Details, returnedProduct.Price, returnedProduct.Stock);
     return newProductVm;
 }
Beispiel #2
0
        public static List<ProductVM> GetAllProducts()
        {
            ProductMapper productMapper = new ProductMapper();
            List<Product> returnedProductsList = productMapper.GetAllProducts();
            List<ProductVM> returnedProductsVm =new List<ProductVM>();
            foreach (var productItem in returnedProductsList)
            {
                ProductVM newProductVm = new ProductVM(productItem.Id, productItem.Name, productItem.Category, productItem.Color,
               productItem.Details, productItem.Price, productItem.Stock);
                returnedProductsVm.Add(newProductVm);
            }

            return returnedProductsVm;
        }
 public ActionResult Edit(ProductVM productVm)
 {
     ProductBL.EditProduct(productVm);
     return RedirectToAction("Index");
 }
Beispiel #4
0
 public static void EditProduct(ProductVM productVM)
 {
     ProductMapper productMapper = new ProductMapper();
     Product inputProduct = new Product(productVM.Id, productVM.Name, productVM.Category, productVM.Color, productVM.Details, productVM.Price, productVM.Stock);
     productMapper.EditProduct(inputProduct);
 }
 public ActionResult Add(ProductVM productVm)
 {
     ProductBL.AddProduct(productVm);
     return RedirectToAction("Index");
 }