예제 #1
0
        public async Task <IActionResult> OnPostRemoveToCartAsync(string productId)
        {
            var basket = await basketApi.GetBasket("swn").ConfigureAwait(false);

            var item = basket.Items.Single(x => x.ProductId == productId);

            basket.Items.Remove(item);

            var basketUpdate = await basketApi.UpdateBasket(basket).ConfigureAwait(false);

            return(RedirectToPage());
        }
예제 #2
0
        public async Task <IActionResult> OnPostRemoveToCartAsync(string productId)
        {
            var basket = await _basketApi.GetBasket("userName");

            var item = basket.Items.Single(x => x.ProductId == productId);

            basket.Items.Remove(item);

            var basketUpdated = await _basketApi.UpdateBasket(basket);

            return(RedirectToPage());
        }
예제 #3
0
        public async Task <IActionResult> OnPostRemoveToCartAsync(string productId)
        {
            var username = "******";
            var basket   = await basketApi.GetBasket(username);

            var item = basket.Items.FirstOrDefault(b => b.ProductId == productId);

            basket.Items.Remove(item);

            var update = await basketApi.UpdateBasket(basket);

            return(RedirectToPage());
        }
예제 #4
0
        public async Task <IActionResult> OnPostRemoveToCartAsync(string productId)
        {
            var userName = "******";
            var basket   = await _basketApi.GetBasket(userName);

            int index = basket.Items.FindIndex(item => item.ProductId == productId);

            basket.Items.RemoveAt(index);

            var updatedBasket = await _basketApi.UpdateBasket(basket);

            return(RedirectToPage());
        }
예제 #5
0
        public async Task <IActionResult> OnPostRemoveToCartAsync(string productId)
        {
            var username = "******";

            var basket = await _basketApi.GetBasket(username);

            var item = basket.Items.Single(i => i.ProductId == productId);

            basket.Items.Remove(item);

            await _basketApi.UpdateBasket(basket);

            return(RedirectToPage());
        }
예제 #6
0
        public async Task <IActionResult> OnPostRemoveToCartAsync(string productId)
        {
            //    return RedirectToPage("./Account/Login", new { area = "Identity" });
            //var product = await _catalogApi.GetCatalog(productId);

            var basket = await _basketApi.GetBasket("bajinder");

            var item = basket.Items.Single(item => item.ProductId == productId);

            basket.Items.Remove(item);

            await _basketApi.UpdateBasket(basket);

            return(RedirectToPage());
        }
예제 #7
0
        public async Task <IActionResult> OnPostAddToCartAsync(string productId)
        {
            var product = await _catalogApi.GetCatalog(productId);

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

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

            var basketUploaded = await _basketApi.UpdateBasket(basket);

            return(RedirectToPage("Cart"));
        }
예제 #8
0
        public async Task <IActionResult> OnPostAddToCartAsync(string productId)
        {
            var product = await catalogApi.GetCatalog(productId).ConfigureAwait(false);

            var userName = "******";
            var basket   = await basketApi.GetBasket(userName).ConfigureAwait(false);

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

            var basketUpdated = await basketApi.UpdateBasket(basket).ConfigureAwait(false);

            return(RedirectToPage("Cart"));
        }
        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    = Quantity,
                Color       = Color
            });

            var basketUpdated = await _basketApi.UpdateBasket(basket);

            return(RedirectToPage("Cart"));
        }
        public async Task <IActionResult> OnPostAddToCartAsync(string productId)
        {
            //if (!User.Identity.IsAuthenticated)
            //    return RedirectToPage("./Account/Login", new { area = "Identity" });
            var product = await _catalogApi.GetCatalog(productId);

            var basket = await _basketApi.GetBasket("bajinder");

            basket.Items.Add(new BasketItemModel
            {
                ProductId   = product.Id,
                ProductName = product.Name,
                Price       = product.Price,
                Color       = "black",
                Quantity    = 1
            });;

            await _basketApi.UpdateBasket(basket);

            return(RedirectToPage("Cart"));
        }