示例#1
0
        public async Task <RedirectToActionResult> AddToCartAsync(GameViewModel gameView, int gameId)
        {
            var selectedGame = await GetGameByIdAsync(gameId);

            if (selectedGame != null)
            {
                await _cart.AddToCartAsync(selectedGame, gameView.Amount);
            }

            return(RedirectToAction("Index"));
        }
示例#2
0
        private async Task AddToCartAsync()
        {
            if (IsInCart)
            {
                return;
            }

            var orderItem = new OrderItemParams()
            {
                ProductId = ProductId,
                Product   = Product
            };

            await CartService.AddToCartAsync(orderItem);

            StateHasChanged();
            NavigationManager.NavigateTo("/cart");
        }