public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ShoppingCart = await _context.ShoppingCarts.FirstOrDefaultAsync(m => m.CartId == id);

            if (ShoppingCart == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ShoppingCart = await _context.ShoppingCarts.FindAsync(id);

            if (ShoppingCart != null)
            {
                _context.ShoppingCarts.Remove(ShoppingCart);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        private async Task <SecondChanceParts.Web.Models.ShoppingCart> Checkout(SecondChanceParts.Web.Models.ShoppingCart cart)
        {
            _httpClient.DefaultRequestHeaders.Accept.Clear();
            _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            StringContent content = new StringContent(JsonSerializer.Serialize(cart));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response = await _httpClient.PostAsync($"{_apiUrl}/api/carts/{cart.CartId}/checkout", content);

            if (!response.IsSuccessStatusCode)
            {
                var errorContent = await response.Content.ReadAsStringAsync();

                throw new Exception($"Error checking out cart: {errorContent}");
            }

            return(cart);
        }