public void SubstractQtyItem(ProductDTO productDto, int quantity) { CartLineDTO line = lineCollection .Where(p => p.Product.ProductID == productDto.ProductID) .FirstOrDefault(); if (line != null) { line.Quantity -= quantity; } }
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; } }