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