Skip to content

Instantly share code, notes, and snippets.

Created Jul 22, 2020
What would you like to do?
public async Task<IActionResult> OnPost(CatalogItemViewModel productDetails)
if (productDetails?.Id == null)
return RedirectToPage("/Index");
await SetBasketModelAsync();
var result = await _basketService.AddItemToBasket(BasketModel.Id, productDetails.Id, productDetails.Price, productDetails.Quantity);
await SetBasketModelAsync();
return result.Match<IActionResult>(
quantity => RedirectToPage(),
validationError => new BadRequestResult());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment