public void AddItem(SANPHAM sp, int quantity) { CartItem line = lineCollection .Where(p => p.Sanpham.ID_SP == sp.ID_SP) .FirstOrDefault(); if (line == null) { lineCollection.Add(new CartItem { Sanpham = sp, Quantity = quantity }); } else { line.Quantity += quantity; if (line.Quantity <= 0) { lineCollection.RemoveAll(l => l.Sanpham.ID_SP == sp.ID_SP); } } }
public void RemoveLine(SANPHAM sp) { lineCollection.RemoveAll(l => l.Sanpham.ID_SP == sp.ID_SP); }