Exemplo n.º 1
0
        public async Task <IActionResult> OnPostCheckOutAsync()
        {
            var userName = "******";

            Cart = await _basketService.GetBasket(userName);

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Order.UserName   = userName;
            Order.TotalPrice = Cart.TotalPrice;

            await _basketService.CheckoutBasket(Order);

            return(RedirectToPage("Confirmation", "OrderSubmitted"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CheckoutBasket([FromBody] BasketItemRequest basketItemRequest)
        {
            var apiUser = BuildApiUser();

            if (apiUser == null)
            {
                return(Unauthorized("Invalid or no X_API_SECRET"));
            }

            try
            {
                await _basketService.CheckoutBasket(apiUser.CustomerKey);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }


            return(Ok("Item has been checkout"));
        }