public BookStoreMutation(IAuthorManager authorManager, IBookManager bookManager)
        {
            Field <AuthorType>(
                "addAuthor",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <AuthorInputType> > {
                Name = "author"
            }),
                resolve: context =>
            {
                var author = context.GetArgument <Author>("author");
                return(authorManager.Add(author));
            });

            Field <BookType>(
                "addBook",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <BookInputType> > {
                Name = "book"
            }),
                resolve: context =>
            {
                var book = context.GetArgument <Book>("book");
                return(bookManager.Add(book));
            });
        }
Exemple #2
0
        public IActionResult Create(Author author)
        {
            if (ModelState.IsValid)
            {
                author.CreatedAt = DateTime.Now;
                _iAuthorManager.Add(author);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }