Esempio n. 1
0
        public void UpdateItem(PhongKhachSan phong, int quantity)
        {
            CartItem item = _ListCart.Where(p => p.Phong.ID == phong.ID).FirstOrDefault();

            if (item != null)
            {
                if (quantity > 0)
                {
                    item.Quantity = quantity;
                }
                else
                {
                    _ListCart.RemoveAll(i => i.Phong.ID == phong.ID);
                }
            }
        }
Esempio n. 2
0
        public void AddItem(PhongKhachSan phong, int quantity)
        {
            CartItem item = _ListCart.Where(p => p.Phong.ID == phong.ID).FirstOrDefault();

            if (item == null)
            {
                _ListCart.Add(new CartItem
                {
                    Phong    = phong,
                    Quantity = quantity
                });
            }
            else
            {
                item.Quantity += quantity;
                if (item.Quantity <= 0)
                {
                    _ListCart.RemoveAll(i => i.Phong.ID == phong.ID);
                }
            }
        }
Esempio n. 3
0
 public void RemoveItem(PhongKhachSan phong)
 {
     _ListCart.RemoveAll(i => i.Phong.ID == phong.ID);
 }