public async Task <IActionResult> UpdateCountries(int proposalId, [FromBody] UpdateProposalCountriesCommand command) { var result = await _mediator.Send(new CommandWithResourceId <int, UpdateProposalCountriesCommand, bool>(proposalId, command)); if (!result) { return(BadRequest()); } return(Ok(result)); }
public SalesSchemaMutationRoot(ProposingClient client) { Field <ProposalSchemaType>( "CreateProposal", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <CreateProposalSchemaType> > { Name = "proposal" }), resolve: context => client.Proposals_CreateProposalAsync(context.GetArgument <CreateProposalCommand>("proposal")) ); FieldAsync <ProposalSchemaType>( "UpdateProposalCountries", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "proposalId" }, new QueryArgument <NonNullGraphType <ListGraphType <NonNullGraphType <ProposalCountryInputSchemaType> > > > { Name = "proposalCountries" }), resolve: async context => { var command = new UpdateProposalCountriesCommand { Countries = context.GetArgument <List <ProposalCountryDto> >("proposalCountries") }; var proposalId = context.GetArgument <int>("proposalId"); await client.Proposals_UpdateCountriesAsync(proposalId, command); return(await client.Proposals_GetProposalAsync(proposalId)); } ); FieldAsync <ProposalSchemaType>( "UpdatePayrollScope", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "proposalId" }, new QueryArgument <NonNullGraphType <ListGraphType <NonNullGraphType <UpdatePayrollCountryScopeSchemaType> > > > { Name = "countryScopes" } ), resolve: async context => { var command = new UpdatePayrollScopeCommand { CountryScopes = context.GetArgument <List <UpdatePayrollCountryScopeDto> >("countryScopes"), }; var proposalId = context.GetArgument <int>("proposalId"); await client.PayrollScope_UpdateScopeAsync(proposalId, command); return(await client.Proposals_GetProposalAsync(proposalId)); } ); FieldAsync <ProposalSchemaType>( "UpdateHrScope", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "proposalId" }, new QueryArgument <NonNullGraphType <ListGraphType <NonNullGraphType <IntGraphType> > > > { Name = "countryIds" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "levelId" } ), resolve: async context => { var command = new UpdateHrScopeCommand { LevelId = context.GetArgument <short>("levelId"), CountryIds = context.GetArgument <List <int> >("countryIds"), }; var proposalId = context.GetArgument <int>("proposalId"); await client.HrScope_UpdateScopeAsync(proposalId, command); return(await client.Proposals_GetProposalAsync(proposalId)); } ); }