Beispiel #1
0
        public ActionResult <CheckoutDto> CalculateTotals(string id, [FromBody] CouponDto coupon)
        {
            try
            {
                return(_shoppingCartManager.CalculateTotals(id, coupon));
            }
            catch (ShoppingCartNotFoundException)
            {
                _logger.LogError($"Shopping cart {id} not found");

                return(NotFound());
            }
        }
        public ActionResult <CheckoutDto> CalculateTotals(string id, [FromQuery(Name = "coupon")] String couponCode)
        {
            try
            {
                return(_shoppingCartManager.CalculateTotals(id, couponCode));
            }
            catch (ShoppingCartNotFoundException)
            {
                _logger.LogError($"Shopping cart {id} not found");

                return(NotFound());
            }
            catch (InvalidCouponException)
            {
                return(BadRequest());
            }
        }
        public ActionResult <CheckoutDto> CalculateTotals(string id)
        {
            try
            {
                return(_shoppingCartManager.CalculateTotals(id));
            }
            catch (ShoppingCartNotFoundException)
            {
                _logger.LogError($"Shopping cart {id} not found");

                return(NotFound());
            }
            catch (MissingDataException ex)
            {
                _logger.LogError($"Cannot calculate checkout price for {id}:\n", ex);

                return(NotFound());
            }
        }