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