Ejemplo n.º 1
0
        public bool CreateBook(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();

            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.Add(bookCategory);
            }

            bookContext.Add(book);
            return(Save());
        }
 public bool CreateReview(Review review)
 {
     reviewContext.Add(review);
     return(Save());
 }
 public bool CreateCategory(Category category)
 {
     categoryContext.Add(category);
     return(Save());
 }
 public bool CreateCountry(Country country)
 {
     countryContext.Add(country);
     return(Save());
 }
 public bool CreateAuthor(Author author)
 {
     authorContext.Add(author);
     return(Save());
 }
 public bool CreateReviewer(Reviewer reviewer)
 {
     reviewerContext.Add(reviewer);
     return(Save());
 }