public async Task UpdateBookPropertiesAsync(BookSearchResultViewModel book, UserBookPropertiesViewModel properties, [FromServices] IBookPropertiesLogic bookLogic)
        {
            try
            {
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

                var bookToSave = new BookSearchResult();
                bookToSave.Title         = book.Title;
                bookToSave.Description   = book.Description;
                bookToSave.CoverImageUrl = book.CoverImageUrl;
                bookToSave.Rating        = ParseExtensions.TryParseDouble(book.Rating);
                bookToSave.RatingCount   = ParseExtensions.TryParseInt(book.RatingCount, 0).Value;
                bookToSave.PublishedDate = ParseExtensions.TryParseDateTime(book.PublishedDate);
                bookToSave.PageCount     = ParseExtensions.TryParseInt(book.PageCount);
                bookToSave.Isbn          = book.Isbn;

                if (book.Authors != null)
                {
                    bookToSave.Authors = book.Authors.Split(",");
                }

                if (book.Genres != null)
                {
                    bookToSave.Genres = book.Genres.Split(",");
                }

                await bookLogic.UpdateBookProperties(userId, bookToSave, properties.IsCurrentlyReading, properties.IsBookToRead, properties.IsInBookshelf, properties.IsInterested);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Unable to update book properties.");

                Response.StatusCode = 500;
            }
        }
        public async Task <JsonResult> SearchBooksAsync(string searchQuery, [FromServices] IBooksClient booksClient)
        {
            var results = await booksClient.SearchBooksAsync(searchQuery);

            List <BookSearchResultViewModel> models = new List <BookSearchResultViewModel>();

            foreach (var result in results)
            {
                BookSearchResultViewModel model = new BookSearchResultViewModel();

                model.Title         = result.Title;
                model.Description   = result.Description;
                model.CoverImageUrl = result.CoverImageUrl;
                model.Rating        = result.Rating == null ? null : result.Rating.ToString();
                model.RatingCount   = result.RatingCount.ToString();
                model.PublishedDate = result.PublishedDate == null ? null : result.PublishedDate.ToString();
                model.PageCount     = result.PageCount == null ? null : result.PageCount.ToString();
                model.Isbn          = result.Isbn;

                if (result.Authors != null)
                {
                    model.Authors = string.Join(", ", result.Authors);
                }

                if (result.Genres != null)
                {
                    model.Genres = string.Join(", ", result.Genres);
                }

                if (result.PublishedDate != null)
                {
                    model.Year = result.PublishedDate.Value.Year.ToString();
                }

                models.Add(model);
            }

            return(Json(models));
        }