예제 #1
0
        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 AddGenreAuthorLink(GenreAuthorLink genreAuthorLink)
 {
     genreAuthorLinkRepo.AddGenreAuthorLink(genreAuthorLink);
 }
예제 #3
0
 public void AddGenreAuthorLink(GenreAuthorLink genreAuthorLink)
 {
     db.GenreAuthorLink.Add(genreAuthorLink);
     Save();
 }