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); } } }
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); } } }
public void RemoveItem(PhongKhachSan phong) { _ListCart.RemoveAll(i => i.Phong.ID == phong.ID); }