public void OnAddDiscountedItemToCart(SalesDealContainer itemToAdd) { var existingBasket = MyCart.FirstOrDefault(s => s.cartDiscountDeal != null && s.cartDiscountDeal.SalesCombination.SalesCombinationID == itemToAdd.SalesCombination.SalesCombinationID); if (existingBasket != null) { existingBasket.AddOne(); } else { MyCart.Add(new CartItem(itemToAdd)); } CartCount = MyCart.Sum(s => s.cartOrderLine.Quantity); CartCost = MyCart.Sum(s => s.cartOrderLine.Price); }
public void OnAddToCart(Product productToAdd) { var existingBasket = MyCart.FirstOrDefault(s => s.cartProduct != null && s.cartProduct.ProductID == productToAdd.ProductID); if (existingBasket != null) { existingBasket.AddOne(); } else { MyCart.Add(new CartItem(productToAdd)); } CartCount = MyCart.Sum(s => s.cartOrderLine.Quantity); CartCost = MyCart.Sum(s => s.cartOrderLine.Price); }