public string AddItem(Product product, decimal quantity)
        {
            var item = this.ProductCartItems
                .Where(p => p.Product.Id == product.Id)
                .FirstOrDefault();

            if (item == null)
            {
                var cartItem = new ProductCartItem
                {
                    Product = product,
                    Quantity = quantity
                };

                this.ProductCartItems.Add(cartItem);
            }
            else
            {
                return "You have already ordered this product!";
            }

            return null;
        }
Beispiel #2
0
        public string AddItem(Product product, decimal quantity)
        {
            var item = this.ProductCartItems
                       .Where(p => p.Product.Id == product.Id)
                       .FirstOrDefault();

            if (item == null)
            {
                var cartItem = new ProductCartItem
                {
                    Product  = product,
                    Quantity = quantity
                };

                this.ProductCartItems.Add(cartItem);
            }
            else
            {
                return("You have already ordered this product!");
            }

            return(null);
        }