public ActionResult Create(BookAuthorViewModel viewModel) { try { if (viewModel.AuthorId == -1) { ViewBag.Message = "Please select an author from the list "; var model = new BookAuthorViewModel { Authors = FillSelectList() }; return(View(model)); } var author = authorRepository.Find(viewModel.AuthorId); Book book = new Book { id = viewModel.BookId, Title = viewModel.Title, Description = viewModel.Descrption, Author = author }; bookRepository.Add(book); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
// GET: Book/Details/5 public ActionResult Details(int id) { var book = bookRepository.Find(id); return(View(book)); }
// GET: Author/Details/5 public ActionResult Details(int id) { var authors = authorReporsitory.Find(id); return(View(authors)); }