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; } }
public static void AddItem(ShoppingCartItemVM shoppingCartItemVm) { ShoppingCartMapper shoppingCartMapper = new ShoppingCartMapper(); ShoppingCartItem shoppingCartItem = new ShoppingCartItem(shoppingCartItemVm.IdProduct, shoppingCartItemVm.Quantity); shoppingCartMapper.AddShoppingCartItem(shoppingCartItem); }