Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public bool UpdateReview(Review review)
        {
            _reviewContext.Update(review);

            return(Save());
        }
Exemplo n.º 3
0
        public bool UpdateCategory(Category category)
        {
            _categoryContext.Update(category);

            return(Save());
        }
Exemplo n.º 4
0
 public bool UpdateReviewer(Reviewer reviewer)
 {
     _reviewerDbContext.Update(reviewer);
     return(Save());
 }
Exemplo n.º 5
0
 public bool UpdateAuthor(Author author)
 {
     _authorRepository.Update(author);
     return(Save());
 }
Exemplo n.º 6
0
 public bool UpdateAuthor(Author author)
 {
     _authorContext.Update(author);
     return(Save());
 }
Exemplo n.º 7
0
        public bool UpdateCountry(Country country)
        {
            _countryContext.Update(country);

            return(Save());
        }