public ActionResult <ShoppingCartDto> AddItemToCart(string id, ItemDto item)
        {
            try
            {
                _shoppingCartManager.AddItemToCart(id, item);

                return(Ok());
            }
            catch (ShoppingCartNotFoundException)
            {
                _logger.LogError($"Shopping cart {id} not found");

                return(NotFound());
            }
        }
Exemple #2
0
        public ActionResult <ShoppingCartDto> AddItemToCart(string id, ItemDto item)
        {
            try
            {
                _shoppingCartManager.AddItemToCart(id, item);

                return(Ok());
            }
            catch (ShoppingCartNotFoundException)
            {
                _logger.LogError($"Shopping cart {id} not found");

                return(NotFound());
            }
            catch (InvalidInputException ex)
            {
                _logger.LogError($"Failed to add item to shopping cart:\n{ex}");

                return(BadRequest());
            }
        }