public void DecreaseQuantity(Furniture furniture) { ShoppingCarItem item = items.Where(p => p.Furniture.FurnitureId == furniture.FurnitureId).FirstOrDefault(); if (item != null) { item.Quantity -= 1; } if (item.Quantity == 0) { RemoveItem(furniture); } }
public void AddItem(Furniture furniture, int quantity) { ShoppingCarItem item = items .Where(p => p.Furniture.FurnitureId == furniture.FurnitureId) .FirstOrDefault(); if (item == null) { items.Add(new ShoppingCarItem { Furniture = furniture, Quantity = quantity }); } else { item.Quantity += quantity; } }