示例#1
0
        public IActionResult Create(Human human)
        {
            if (ModelState.IsValid)
            {
                _humanRepository.AddHuman(human);
            }

            return(RedirectToRoute(new { controller = "Human", action = "Index" }));
        }
示例#2
0
        public IActionResult Create(HumanCreateViewModel humanCreateViewModel)
        {
            if (ModelState.IsValid)
            {
                _humanRepository.AddHuman(humanCreateViewModel.Human);
            }

            return(View());
        }
示例#3
0
        public RootMutation(IHumanRepository humanRepository)
        {
            this.Name        = "Mutation";
            this.Description = "The mutation type, represents all updates we can make to our data.";

            this.FieldAsync <HumanObject, Human>(
                "createHuman",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <HumanInputObject> >()
            {
                Name        = "human",
                Description = "The human you want to create."
            }),
                resolve: context =>
            {
                var human = context.GetArgument <Human>("human");
                return(humanRepository.AddHuman(human, context.CancellationToken));
            });
        }
示例#4
0
 public async Task AddHuman(AddHumanRequest request)
 {
     var human = _mapper.Map <AddHumanRequest, Human>(request);
     await _repository.AddHuman(human);
 }