public IActionResult ViewApiInfoForSingleBook(string bookId) { try { User currentUser = CurrentUser(); BookInfo apiBook = _libraryDAL.GetBookInfo(bookId); List <Author> authors = new List <Author>(); TempData["AlreadyHasBook"] = DoesUserHaveThisBook(currentUser.Id, bookId); TempData["AlreadyWroteReview"] = HasUserWrittenReview(currentUser.Id, bookId); if (apiBook.authors is not null) { foreach (Author author in apiBook.authors) { if (author.author.key is not null) { string authorId = author.author.key; Author apiAuthor = _libraryDAL.GetAuthorInfo(authorId); authors.Add(apiAuthor); } } apiBook.authors = authors; } List <BookReview> reviewForThisBook = _libraryDB.BookReviews.Where(x => x.TitleIdApi == apiBook.key).ToList(); if (reviewForThisBook.Count > 0) { TempData["reviewsExist"] = "true"; } return(View(apiBook)); } catch (Exception) { TempData["errorMessage"] = "Something went wrong. We cannot display that title at the moment"; return(RedirectToAction("ErrorMessage")); } }