Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2020 23:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dcomartin/8bf800a915b934fe64858d44e823810b to your computer and use it in GitHub Desktop.
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