示例#1
0
    public async Task <IActionResult> OnPost(CatalogItemViewModel productDetails)
    {
        if (productDetails?.Id == null)
        {
            return(RedirectToPage("/Index"));
        }

        var username = GetOrSetBasketCookieAndUserName();
        var basket   = await _basketService.AddItemToBasket(username,
                                                            productDetails.Id, productDetails.Price);

        BasketModel = await _basketViewModelService.Map(basket);

        return(RedirectToPage());
    }