public async Task <IActionResult> OnGetAsync(string productId)
        {
            if (productId == null)
            {
                return(NotFound());
            }

            Product = await _catalogApi.GetCatalogById(productId);

            if (Product == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAddToCartAsync(string productId)
        {
            var product = await _catalogApi.GetCatalogById(productId);

            var userName = "******";
            var shopCart = await _shopCartApi.GetShopCart(userName);

            shopCart.Items.Add(new ShopCartItemModel
            {
                ProductId   = productId,
                ProductName = product.Name,
                Price       = product.Price,
                Quantity    = 1,
                Color       = "black"
            });

            var shopCartUpdated = await _shopCartApi.UpdateShopCart(shopCart);

            return(RedirectToPage("Cart"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAddToCartAsync(string productId)
        {
            var product = await _catalogApi.GetCatalogById(productId);

            var userName = "******";
            var basket   = await _basketApi.GetBasket(userName);

            basket.Items.Add(new BasketItemModel
            {
                ProductID   = productId,
                ProductName = product.Name,
                Price       = product.Price,
                Quantity    = 1,
                Color       = "Black"
            });

            var basketUpdated = await _basketApi.UpdateBasket(basket);

            return(RedirectToPage("Cart"));
        }