예제 #1
0
        public async Task <ActionResult <ShoppingCartItem> > UpdateShoppingCartItem(ShoppingCartItem shoppingCartItem)
        {
            try
            {
                var shoppingCartItemToUpdate = await _shoppingCartItemRepository.GetShoppingCartItem(shoppingCartItem.ShoppingCartItemId);

                if (shoppingCartItemToUpdate == null)
                {
                    return(NotFound($"Shopping cart item with Id = {shoppingCartItem.ShoppingCartItemId} not found"));
                }
                else
                {
                    var result = await _shoppingCartItemRepository.UpdateShopingCartItem(shoppingCartItem);

                    return(result);
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error with updating data to the database"));
            }
        }