public ActionResult Create(Book book, string[] selectedAuthors) { PopulateLanguagesDropDownList(); PopulateGenresDropDownList(); PopulateBookAuthors(book); try { if (ModelState.IsValid) { Language l = languageDAO.Find(book.LanguageID); Genre g; if (book.GenreID == -1) { g = new Genre(); g.Id = -1; g.Name = ""; } else { g = genreDAO.Find(book.GenreID); } book.Id = dao.CurrentID() + 1; book.Language = l; book.Genre = g; UpdateBookAuthors(selectedAuthors, book); if (book.Authors.Count == 0) { ModelState.AddModelError("", "At least one author should be selected"); return(View(book)); } dao.Create(book); return(RedirectToAction("Index")); } } catch { ModelState.AddModelError("", "Unable to save changes."); } return(View(book)); }