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 AddItemWithPurchase(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; } }
public void AddItem(Furniture furniture, int quantity) { ShoppingCarItem item = Viewitems .Where(p => p.Furniture.FurnitureId == furniture.FurnitureId) .FirstOrDefault(); if (item == null) { Viewitems.Add(new ShoppingCarItem { Furniture = furniture, Quantity = quantity }); } else { item.Quantity += quantity; } if (Viewitems.Count() == 2) { Viewitems.RemoveAt(0); } }