//GET: Details public IActionResult Details(int id) { var book = bookService.GetBookById(id); var vm = new BookDetailsVm(); vm.ID = id; vm.Title = book.Title; vm.ISBN = book.ISBN; vm.Description = book.Description; vm.Author = book.Author; vm.AuthorID = book.AuthorID; vm.Copies = book.Copies.ToList(); return(View(vm)); }
public ActionResult Details(int id) { if (id == 0) { return(NotFound()); } var vm = new BookDetailsVm { Book = _bookService.FindBook(id), BookCopies = _bookCopyService.GetAllBookCopies().Where(b => b.DetailsId == id).ToList() }; return(View(vm)); }
// GET: BookDetails/Details/5 public async Task <IActionResult> Details(int id) //Was int? { var bookDetails = bookService.GetBookDetailsById(id); var displayBookVm = new BookDetailsVm(); displayBookVm.ID = bookDetails.ID; displayBookVm.Author = authorService.GetAuthorById(bookDetails.AuthorID).Name; displayBookVm.AuthorID = bookDetails.AuthorID; displayBookVm.Titel = bookDetails.Titel; displayBookVm.ISBN = bookDetails.ISBN; displayBookVm.Details = bookDetails.Details; displayBookVm.BookCopies = bookDetails.BookCopies.ToList(); displayBookVm.CanBeRemoved = bookService.CanRemoveBookDetails(id); return(View(displayBookVm)); }
//// GET: Books/Details/5 public async Task <IActionResult> Details(int id) { if (ModelState.IsValid) { var vm = new BookDetailsVm(); var book = bookservice.GetBook(id); vm.Title = book.Title; vm.Description = book.Description; vm.ISBN = book.ISBN; vm.AuthorId = book.AuthorID; vm.Author = authorService.GetAuthor(book.AuthorID); vm.Id = book.ID; vm.Copies = book.Copies; return(View(vm)); } return(RedirectToAction("Error", "Home", "")); }