public ActionResult Delete(int bookId) { var book = bookService.FindBookById(bookId); genreBookLinksService.DeleteGenreBookLink(book.GenreId, book.Id); genreAuthorLinksService.DeleteGenreAuthorLink(book.GenreId, book.AuthorId); authorBookLinksService.DeleteAuthorBookLink(book.AuthorId, book.Id); var reviewsList = reviewService.GetAllReviewsByBookId(bookId); foreach (var review in reviewsList) { reviewService.DeleteReview(review); } bookService.DeleteBook(book); return(RedirectToAction("Index")); }
public ActionResult Delete(int authorId) { var author = authorService.GetAuthorById(authorId); var genresList = genreAuthorLinkService.GetAllGenresByAuthorId(author.Id); foreach (var genre in genresList) { genreAuthorLinkService.DeleteGenreAuthorLink(genre.Id, author.Id); } var bookList = authorBookLinksService.GetBooksByAuthorId(authorId); foreach (var book in bookList) { authorBookLinksService.DeleteAuthorBookLink(author.Id, book.Id); } authorService.DeleteAuthor(author); return(RedirectToAction("Index")); }