public bool UpdateBook(List <int> authorsId, List <int> categoriesId, Book book) { var authors = _bookContext.Authors.Where(a => authorsId.Contains(a.Id)).ToList(); var categories = _bookContext.Categories.Where(c => categoriesId.Contains(c.Id)).ToList(); var bookAuthorsToDelete = _bookContext.BookAuthors.Where(b => b.BookId == book.Id); var bookCategoriesToDelete = _bookContext.BookCategories.Where(b => b.BookId == book.Id); _bookContext.RemoveRange(bookAuthorsToDelete); _bookContext.RemoveRange(bookCategoriesToDelete); foreach (var author in authors) { var bookAuthor = new BookAuthor() { Author = author, Book = book }; _bookContext.Add(bookAuthor); } foreach (var category in categories) { var bookCategory = new BookCategory() { Category = category, Book = book }; _bookContext.Add(bookCategory); } _bookContext.Update(book); return(Save()); }
public bool UpdateCategory(Category category) { _categoryContext.Update(category); return(Save()); }
public bool UpdateAuthor(Author author) { _authorContext.Update(author); return(Save()); }
public bool UpdateReviewer(Reviewer reviewer) { _reviewerContext.Update(reviewer); return(Save()); }
public bool UpdateCountry(Country country) { _countryContext.Update(country); return(Save()); }
public bool UpdateReview(Review review) { _reviewContext.Update(review); return(Save()); }