public async Task <ActionResult> Details(int id)
        {
            var album = await _albumQueryService.GetAlbumDetails(id);

            if (album != null)
            {
                return(new JsonResult(album));
            }

            Log.Logger.Warning("User tried to retrieve album with {id} which doesn't exist", id);
            return(NotFound());
        }
        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));
        }
        public async Task <JsonResult> Details(int id)
        {
            _logger.LogInformation("Get album with id {id}", id);
            try
            {
                var album = await _albumQueryService.GetAlbumDetails(id);

                if (album != null)
                {
                    return(new JsonResult(album));
                }

                Log.Logger.Warning("User tried to retrieve album with {id} which doesn't exist", id);
                return(Json(null));
            }
            catch (DbException ex)
            {
                Log.Logger.Error(ex, "Failed to get album with id {id}", id);
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json("Error occurred finding Album" + ex.Message));
            }
        }