Пример #1
0
        public SalesSchemaQueryRoot(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
        {
            Field <ProposalSchemaType>(
                "Proposal",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context => client.Proposals_GetProposalAsync(context.GetArgument <int>("id"))
                );

            Field <ProposalListPageSchemaType>(
                "ProposalListPage",
                arguments: new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "page", DefaultValue = 1
            },
                    new QueryArgument <IntGraphType> {
                Name = "rowsPerPage", DefaultValue = 25
            },
                    new QueryArgument <StringGraphType> {
                Name = "orderBy", DefaultValue = "name"
            },
                    new QueryArgument <StringGraphType> {
                Name = "order", DefaultValue = "asc"
            },
                    new QueryArgument <IntGraphType> {
                Name = "hasProduct"
            },
                    new QueryArgument <IntGraphType> {
                Name = "hasAnyProduct"
            }
                    ),
                resolve: context => client.Proposals_GetProposalsAsync(
                    context.GetArgument <int>("page"),
                    context.GetArgument <int>("rowsPerPage"))
                );

            Field <ListGraphType <CountrySchemaType> >(
                "Countries",
                resolve: context => client.Countries_GetCountriesAsync()
                );

            Field <ListGraphType <ProductModelSchemaType> >(
                "ProductModels",
                resolve: context => cache.ProductModels.Values
                );
        }
Пример #2
0
        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));
            }
                );
        }