Example #1
0
        public void SubstractQtyItem(ProductDTO productDto, int quantity)
        {
            CartLineDTO line = lineCollection
                               .Where(p => p.Product.ProductID == productDto.ProductID)
                               .FirstOrDefault();

            if (line != null)
            {
                line.Quantity -= quantity;
            }
        }
Example #2
0
        public void AddItem(ProductDTO productDto, int quantity)
        {
            CartLineDTO line = lineCollection
                               .Where(p => p.Product.ProductID == productDto.ProductID)
                               .FirstOrDefault();

            if (line == null)
            {
                lineCollection.Add(new CartLineDTO
                {
                    Product  = productDto,
                    Quantity = quantity
                });
            }
            else
            {
                line.Quantity += quantity;
            }
        }