public async Task <IActionResult> OnPostAsync(int productId, int quantity = 1)
        {
            ShoppingCart cart = await _starzApplicationService.GetShoppingCartAsync();

            await cart.AddProductByIdAsync(productId, quantity);

            return(RedirectToPage("/Cart/Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(string couponCode)
        {
            ShoppingCart cart = await _starzApplicationService.GetShoppingCartAsync();

            await cart.RemoveCouponByCodeAsync(couponCode);

            return(RedirectToPage("/Cart/Index"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(int productId, int quantity)
        {
            ShoppingCart cart = await _starzApplicationService.GetShoppingCartAsync();

            ShoppingCartItem item = cart.Items.FirstOrDefault(o => o.Product.ProductId == productId);

            if (item == null)
            {
                throw new InvalidOperationException("Could not find that product.");
            }
            item.Quantity = quantity;
            await item.SaveChanges();

            return(RedirectToPage("/Cart/Index"));
        }
        public async Task <IActionResult> OnPostAsync(string couponCode)
        {
            ShoppingCart cart = await _starzApplicationService.GetShoppingCartAsync();

            try
            {
                await cart.AddCouponByCodeAsync(couponCode);

                return(RedirectToPage("/Cart/Index"));
            }
            catch (InvalidOperationException e)
            {
                return(RedirectToPage("/Cart/Index", new { couponError = e.Message }));
            }
        }
 public async Task OnGetAsync()
 {
     _cart = await _starzApplicationService.GetShoppingCartAsync();
 }
Exemplo n.º 6
0
        public async Task OnGetAsync(string couponError = null)
        {
            _cart = await _starzApplicationService.GetShoppingCartAsync();

            CouponError = couponError;
        }