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