Пример #1
0
        public List<Cartitem> Add(string Product, int Quantity, double Price)
        {
            var cartItem = new Cartitem
            {
                Price = Price,
                Product = Product,
                Quantity = Quantity
            };
            cart.Add(cartItem);

            return cart;
        }
Пример #2
0
        //public List<Cartitem> Remove(Cartitem cartItem)
        public List<Cartitem> Remove(string Product, int Quantity, double Price)
        {
            var cartItem = new Cartitem
            {
                Price = Price,
                Product = Product,
                Quantity = Quantity
            };
            var item = cart.FirstOrDefault(c => c.Product == cartItem.Product);
            if (item != null)
            {
                cart.Remove(item);
            }

            return cart;
        }