public void Add(Product product,int quantity) { CartItem ct; ct = Items.Where(ci => ci.Product.ProductId == product.ProductId).SingleOrDefault(); if ( ct== null) { ct = new CartItem { Product = product, Quantity = quantity }; Items.Add(ct); } else { ct.Quantity += quantity; } }
public void Remove(Product product) { Items.RemoveAll(p => p.Product.ProductId == product.ProductId); }