Created
November 10, 2016 00:36
-
-
Save dcomartin/6845c25f7d4c9bc35ae9c5fb3dec3128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IActionResult> AddToCart(int id, CancellationToken requestAborted) | |
{ | |
// Retrieve the album from the database | |
var addedAlbum = await DbContext.Albums | |
.SingleAsync(album => album.AlbumId == id); | |
// Add it to the shopping cart | |
var cart = ShoppingCart.GetCart(DbContext, HttpContext); | |
await cart.AddToCart(addedAlbum); | |
await DbContext.SaveChangesAsync(requestAborted); | |
_logger.LogInformation("Album {albumId} was added to the cart.", addedAlbum.AlbumId); | |
// Go back to the main store page for more shopping | |
return RedirectToAction("Index"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment