public async Task <IActionResult> Create(Order model, string action)
        {
            if (ModelState.IsValid)
            {
                var user = _appUserParser.Parse(HttpContext.User);
                await _orderSvc.CreateOrder(model);

                //Empty basket for current user.
                await _basketSvc.CleanBasket(user);

                //Redirect to historic list.
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public async Task <IActionResult> Create(Order model, string action)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = _appUserParser.Parse(HttpContext.User);
                    await _orderSvc.CreateOrder(model);

                    //Empty basket for current user.
                    await _basketSvc.CleanBasket(user);

                    //Redirect to historic list.
                    return(RedirectToAction("Index"));
                }
            }
            catch (BrokenCircuitException ex)
            {
                ModelState.AddModelError("Error", "It was not possible to create a new order, please try later on");
            }
            return(View(model));
        }
        public async Task <IActionResult> Checkout(Dictionary <string, int> items, string action)
        {
            try
            {
                var user   = _appUserParser.Parse(HttpContext.User);
                var basket = await _basketSvc.SetQuantities(user.Id, items);

                if (action == "[ Checkout ]")
                {
                    await _basketSvc.CleanBasket(basket.BuyerId);

                    return(View());
                }
            }
            catch (BrokenCircuitException)
            {
                // Catch error when Basket.api is in circuit-opened mode
                HandleBrokenCircuitException();
            }

            return(View());
        }