public ActionResult AddBook(IFormCollection collection, Book book) { if (!ModelState.IsValid) { var model = new WritersAndGenres { Book = book, Genres = bookService.GetAllGenre(), Writer = bookService.GetWriters() }; return(View("AddBook", model)); } try { var genreList = collection["bookGenre"]; var writerId = collection["writerId"]; bookService.InsertBook(book, writerId, genreList); return(RedirectToAction("Books")); } catch (Exception ex) { Console.WriteLine(ex.Message); return(View()); } }