示例#1
0
        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);
                }
            }
        }
示例#2
0
        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);
                }
            }
        }
示例#3
0
 public int GetProductQuantity(SANPHAM sp)
 {
     return(lineCollection.Where(s => s.Sanpham.MaQA == sp.MaQA)
            .Single()
            .Quantity);
 }
示例#4
0
 public void RemoveLine(SANPHAM sp)
 {
     lineCollection.RemoveAll(l => l.Sanpham.MaQA == sp.MaQA);
 }