public IActionResult Details(int?id) { if (id == null) { throw new ArgumentException(); } Book book = bookServices.FindBook(id); FullBookView result = GetDetails(book); if (result == null) { return(RedirectToAction(nameof(Books))); } return(View(result)); }
private FullBookView GetDetails(Book book) { if (book == null) { return(null); } Author author = authorServices.FindAuthor(book.AuthorId); string authorFullName = NameRefactorer .GetFullName(author.FirstName, author.MiddleName, author.LastName); FullBookView result = new FullBookView { Id = book.Id, Title = book.Title, Genre = book.Genre, AuthorName = authorFullName, Year = book.Year, Pages = book.Pages, SavedTimes = bookServices.GetBookSavedTimes(book) }; return(result); }