public async Task <IActionResult> AddToCart(int id) { // Retrieve the album from the database var addedAlbum = await _albumQueryService.GetAlbumDetails(id); // Add it to the shopping cart await _cartCommandService.AddToCart(GetCartId(), addedAlbum); // Return the cart json var viewModel = await GetCart(); return(Json(viewModel)); }
public async Task <IActionResult> AddToCart(int id, CancellationToken requestAborted) { _logger.LogInformation("POST request for 'api/{albumId}'", id); // Retrieve the album from the database var addedAlbum = await _albumQueryService.GetAlbumDetails(id); // Add it to the shopping cart await _cartCommandService.AddToCart(GetCartId(), addedAlbum, requestAborted); // Return the cart json var viewModel = await GetCart(); return(Json(viewModel)); }