public void UpdateItem(SANPHAM sp, int quantity) { CartItem line = lineCollection .Where(p => p.Sanpham.MaQA == sp.MaQA) .FirstOrDefault(); if (line != null) { if (quantity > 0) { line.Quantity = quantity; } else { lineCollection.RemoveAll(l => l.Sanpham.MaQA == sp.MaQA); } } }
public void AddItem(SANPHAM sp, int quantity) { CartItem line = lineCollection .Where(p => p.Sanpham.MaQA == sp.MaQA) .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.MaQA == sp.MaQA); } } }
public int GetProductQuantity(SANPHAM sp) { return(lineCollection.Where(s => s.Sanpham.MaQA == sp.MaQA) .Single() .Quantity); }
public void RemoveLine(SANPHAM sp) { lineCollection.RemoveAll(l => l.Sanpham.MaQA == sp.MaQA); }