public async Task <IActionResult> OnPostRemoveToCartAsync(string productId) { var userName = "******"; var basket = await _basketApi.GetBasketAsync(userName); var item = basket.Items.Single(r => r.ProductId == productId); basket.Items.Remove(item); var basketUpdated = await _basketApi.UpdateBasketAsync(basket); return(RedirectToPage()); }
public async Task <IActionResult> OnPostAddToCartAsync(string productId) { var product = await _catalogApi.GetCatalogByIdAsync(productId); var userName = "******"; var basket = await _basketApi.GetBasketAsync(userName); basket.Items.Add(new BasketItemModel { ProductId = productId, ProductName = product.Name, Price = product.Price, Quantity = 1, Color = "Black" }); var backetUpdated = await _basketApi.UpdateBasketAsync(basket); return(RedirectToPage("Cart")); }