Beispiel #1
0
        public async Task <IActionResult> Index(Dictionary <string, int> quantities, string couponCode, string action)
        {
            try
            {
                var user = _appUserParser.Parse(HttpContext.User);

                var vm = await _basketSvc.GetBasket(user);

                if (action == "[ Submit Coupon ]")
                {
                    var updatedBasket = await _couponSvc.Apply(vm, couponCode);

                    await _basketSvc.ApplyCoupon(updatedBasket);
                }
                if (action == "[ Update ]")
                {
                    var basket = await _basketSvc.SetQuantities(user, quantities);
                }

                if (action == "[ Checkout ]")
                {
                    return(RedirectToAction("Create", "Order"));
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }

            return(View());
        }