public ActionResult Create(Book book) { if (ModelState.IsValid) { book.IsFavourite = false; bookService.AddBook(book); //Adding AuthorToBook var authorBookLink = new AuthorBookLink(); authorBookLink.AuthorId = book.AuthorId; authorBookLink.BookId = book.Id; authorBookLinksService.AddAuthorBookLink(authorBookLink); //Adding GenreToBook var genreBookLink = new GenreBookLink(); genreBookLink.BookId = book.Id; genreBookLink.GenreId = book.GenreId; genreBookLinksService.AddGenreBookLink(genreBookLink); //Adding GenreToAuthor var genreAuthorLink = new GenreAuthorLink(); genreAuthorLink.AuthorId = book.AuthorId; genreAuthorLink.GenreId = book.GenreId; genreAuthorLinksService.AddGenreAuthorLink(genreAuthorLink); return(RedirectToAction("Index")); } else { ViewBag.Genres = genreService.GetAllGenres(); ViewBag.Authors = authorService.GetAllAuthors(); return(View(book)); } }
public void AddGenreBookLink(GenreBookLink genreBookLink) { genreBookLinksRepo.AddGenreBookLink(genreBookLink); }
public void AddGenreBookLink(GenreBookLink genreBookLink) { db.GenreBookLink.Add(genreBookLink); Save(); }