public void AddProductToCart(string shoppingCartId, Product product) { lock (_lock) { ShoppingCart shoppingCart = GetById(shoppingCartId); ShoppingCartItem item = shoppingCart.ShoppingCartItems.FirstOrDefault(c => c.Product.ProductNumber == product.ProductNumber); if (item == null) { item = new ShoppingCartItem { Id = product.ProductNumber, Product = product, Quantity = 1, Currency = shoppingCart.Currency }; shoppingCart.ShoppingCartItems.Add(item); } else { item.Quantity++; } UpdatePrices(shoppingCart); } }
void IShoppingCartRepository.AddProductToCart(string shoppingCartId, Product product) { AddProductToCartDelegate(shoppingCartId, product); }