/// <summary> /// Updates a cart item /// </summary> /// <param name="cart"> /// Models.Cart: the current cart /// </param> /// <param name="itemId"> /// int: a flummery's item ID /// </param> /// <param name="qty"> /// int: the flummery's new quantity /// </param> private async Task UpdateCartItems(Models.Cart cart, int itemId, int qty) { bool containsCartItem = false; if (cart.CartItems != null) { foreach (var oneCartItem in cart.CartItems) { if (oneCartItem.ProductId == itemId) { oneCartItem.Qty += qty; containsCartItem = true; await _cartItem.Update(oneCartItem); break; } } } if (!containsCartItem) { var newCartItem = new Models.CartItem { CartId = cart.Id, ProductId = itemId, Qty = qty }; await _cartItem.Create(newCartItem); } }