Exemplo n.º 1
0
        public bool BindProduct(Guid basketId, ProductModel product, int amount)
        {
            var basket = GetBasket(basketId);

            if (basket == null)
            {
                throw new ArgumentNullException("Basket is not found");
            }

            if (amount <= 0)
            {
                Console.WriteLine("{0} cannot be added. Product quantity must be greater than 0", product.Title);
                return(false);
            }

            basket.Products.Add(product, amount);
            basket.SubTotal       = BasketHelper.GetSubTotal(basket);
            basket.DeliveryPrice += CalculateTotalDeliveryPrice(basket);

            return(true);
        }