コード例 #1
0
        public BookMutation(BookCommandHandler commandHandler)
        {
            Field <BookType>(
                "createBook",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <BookInputType> > {
                Name = "book", Description = "book"
            }
                    ),
                resolve: context =>
            {
                //var human = context.GetArgument<Human>("human");
                var book    = context.GetArgument <Book>("book");
                var command = new CreateBookCommand
                {
                    AuthorId    = book.AuthorId,
                    CategoryId  = book.CategoryId,
                    CountryId   = book.CountryId,
                    LanguageId  = book.LanguageId,
                    PublisherId = book.PublisherId,
                    Description = book.Description,
                    Title       = book.Title
                };

                /*var command = new CreateBookCommand
                 * {
                 *  AuthorId = context.GetArgument<int>("authorId"),
                 *  CategoryId = context.GetArgument<int>("categoryId"),
                 *  CountryId = context.GetArgument<int>("countryId"),
                 *  LanguageId = context.GetArgument<int>("languageId"),
                 *  PublisherId = context.GetArgument<int>("publisherId"),
                 *  Description = context.GetArgument<string>("description"),
                 *  Title = context.GetArgument<string>("title")
                 * };*/

                return(commandHandler.Handle(command));
            });
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] RegisterBookCommnad command)
        {
            var result = _handler.Handle(command);

            return(await Response(result, _handler.Notifications));
        }