public static float ItemPrice(ShoppingCartItem shoppingCartItem) { ProductMapper productMapper = new ProductMapper(); Product product = productMapper.GetProduct(shoppingCartItem.IdProduct); return product.Price * shoppingCartItem.Quantity; }
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; }
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; } }