Exemple #1
0
        public Author CreateAuthor([Service] BooksContext context, AuthorAndBook authorAndBook)
        {
            var author = new Author()
            {
                Name  = authorAndBook.AuthorName,
                Books = new List <Book>
                {
                    new Book {
                        Title = authorAndBook.Title
                    }
                }
            };

            context.Authors.Add(author);
            context.SaveChanges();

            return(author);
        }
Exemple #2
0
        public Author CreateAuthorWithArgumentDescription([Service] BooksContext context,
                                                          [GraphQLDescription("Argument description: Author with a book description")]
                                                          AuthorAndBook authorAndBook)
        {
            var author = new Author()
            {
                Name  = authorAndBook.AuthorName,
                Books = new List <Book>
                {
                    new Book {
                        Title = authorAndBook.Title
                    }
                }
            };

            context.Authors.Add(author);
            context.SaveChanges();

            return(author);
        }