Пример #1
0
        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);
                }
            }
        }
Пример #2
0
 public void RemoveLine(SANPHAM sp)
 {
     lineCollection.RemoveAll(l => l.Sanpham.ID_SP == sp.ID_SP);
 }