public bool UpdateBook(List <int> authorId, List <int> categorieId, Book book) { var authors = _bookDBContext.Authors.Where(a => authorId.Contains(a.Id)).ToList(); var categories = _bookDBContext.Categories.Where(c => categorieId.Contains(c.Id)).ToList(); var bookauthortodelete = _bookDBContext.BookAuthors.Where(b => b.BookId == book.Id); var bookcategorytodelete = _bookDBContext.BookCategories.Where(c => c.BookId == book.Id); _bookDBContext.RemoveRange(bookauthortodelete); _bookDBContext.RemoveRange(bookcategorytodelete); foreach (var a in authors) { var bookauthor = new BookAuthor { Author = a, Book = book }; } foreach (var c in categories) { var bookcategories = new BookCategory { Category = c, Book = book }; } _bookDBContext.Update(book); return(Save()); }
public bool DeleteReviews(List <Review> reviews) { _reviewRepository.RemoveRange(reviews); return(Save()); }