Exemplo n.º 1
0
        public async Task <ActionResult> AddPromoCode(string promoCode)
        {
            try
            {
                var shoppingCart = await _shoppingCartService.AddPromoCodeAsync(promoCode);

                return(Redirect("Index"));
            }
            catch (InvalidPromoCodeException e)
            {
                ModelState.AddModelError("PromoCodesAdded", "Failed to add promocode: Invalid promo code - " + e.Message);
                ViewBag.ClientInfo = await GetActivePayPalClientAccountAsync();

                return(View("Index", await _shoppingCartService.GetShoppingCartAsync()));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("PromoCodesAdded", "Failed to add promocode: " + e.Message);
                ViewBag.ClientInfo = await GetActivePayPalClientAccountAsync();

                return(View("Index", await _shoppingCartService.GetShoppingCartAsync()));
            }
        }