コード例 #1
0
        public bool CreateBook(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();

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

            return(Save());
        }
コード例 #2
0
 public bool CreateReviewer(Reviewer reviewer)
 {
     _reviewerContext.Add(reviewer);
     return(Save());
 }
コード例 #3
0
 public bool CreateCategory(Category category)
 {
     _categoryContext.Add(category);
     return(Save());
 }
コード例 #4
0
 public bool CreateCountry(Country country)
 {
     _countryContext.Add(country);
     return(Save());
 }
コード例 #5
0
 public bool CreateAuthor(Author author)
 {
     _authorContext.Add(author);
     return(Save());
 }
コード例 #6
0
 public bool CreateReview(Review review)
 {
     _reviewContext.Add(review);
     return(Save());
 }