예제 #1
0
        public static float ItemPrice(ShoppingCartItem shoppingCartItem)
        {
            ProductMapper productMapper = new ProductMapper();
            Product product = productMapper.GetProduct(shoppingCartItem.IdProduct);

            return product.Price * shoppingCartItem.Quantity;
        }
예제 #2
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;
 }
예제 #3
0
 public static Boolean AddItem(ShoppingCartItemVM shoppingCartItemVm)
 {
     ProductMapper productMapper = new ProductMapper();
     Product product = productMapper.GetProduct(shoppingCartItemVm.IdProduct);
     if (product.Stock >= shoppingCartItemVm.Quantity)
     {
         ShoppingCartMapper shoppingCartMapper = new ShoppingCartMapper();
         ShoppingCartItem shoppingCartItem = new ShoppingCartItem(shoppingCartItemVm.IdProduct,
             shoppingCartItemVm.Quantity);
         shoppingCartMapper.AddShoppingCartItem(shoppingCartItem);
         return true;
     }
     else
     {
         return false;
     }
 }