Ejemplo n.º 1
0
        public bool UpdateBook(List <int> authorId, List <int> categoriesId, Book book)
        {
            //find the author and catgeories list

            var authors    = _bookContext.Authors.Where(a => authorId.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()
                {
                    Book     = book,
                    Category = category
                };
                _bookContext.Update(bookCategory);
            }
            return(Save());
        }
 public bool UpdateAuthor(Author author)
 {
     _authorContext.Update(author);
     return(Save());
 }
 public bool UpdateReview(Review review)
 {
     _reviewContext.Update(review);
     return(Save());
 }
 public bool UpdateReviewer(Reviewer reviewer)
 {
     _ReviewerContext.Update(reviewer);
     return(Save());
 }
Ejemplo n.º 5
0
 public bool UpdateCategory(Category category)
 {
     _categoryContext.Update(category);
     return(Save());
 }
Ejemplo n.º 6
0
 public bool UpdateCountry(Country country)
 {
     _countryContext.Update(country);
     return(Save());
 }