Пример #1
0
 public ProposalSchemaType(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
 {
     Name = "Proposal";
     Field(x => x.Id, nullable: false);
     Field(x => x.Name, nullable: true);
     Field(x => x.ClientName, nullable: true);
     Field(x => x.Comments, nullable: true);
     Field(x => x.Countries, nullable: true, type: typeof(ListGraphType <ProposalCountrySchemaType>));
     Field(x => x.ProductModelId, nullable: true);
     Field(x => x.ProductIds, nullable: true);
     this.Extend(client, cache, accessor);
 }
Пример #2
0
 public ComponentSchemaType(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
 {
     Name = "Component";
     Field(x => x.Id, nullable: false);
     Field(x => x.Name, nullable: true);
     Field(x => x.FullName, nullable: true);
     Field(x => x.IsActive, nullable: true);
     Field(x => x.SortOrder, nullable: true);
     Field(x => x.ProductId, nullable: true);
     Field(x => x.ComponentTypeID, nullable: true);
     this.Extend(client, cache, accessor);
 }
Пример #3
0
 public UpdatePayrollCountryScopeSchemaType(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
 {
     Name = "UpdatePayrollCountryScope";
     Field(x => x.CountryId, nullable: true);
     Field(x => x.LevelId, nullable: true);
     Field(x => x.WeeklyPayees, nullable: true);
     Field(x => x.BiWeeklyPayees, nullable: true);
     Field(x => x.SemiMonthlyPayees, nullable: true);
     Field(x => x.MonthlyPayees, nullable: true);
     Field(x => x.Reporting, nullable: true);
     Field(x => x.PayslipStorage, nullable: true);
     this.Extend(client, cache, accessor);
 }
Пример #4
0
 partial void Extend(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
 {
     Field <ListGraphType <ProductDefinitionSchemaType> >(
         "products",
         resolve: context =>
     {
         var model = cache.ProductModels[context.Source.ProductModelId];
         return(context.Source.ProductIds
                .GetBits()
                .Select(id => model.Products.First(p => p.Id == id)));
     }
         );
     Field <PayrollCountryScopeSchemaType, PayrollCountryScopeViewModel>()
     .Name("payrollScope")
     .ResolveAsync(context => {
         var loader = accessor.Context.GetOrAddBatchLoader <Tuple <int, int>, PayrollCountryScopeViewModel>(
             "GetPayrollCountryScopes",
             async keys =>
         {
             var countriesByProposal = await Task.WhenAll(keys
                                                          .GroupBy(key => key.Item1)
                                                          .Select(group => client.PayrollScope_GetCountryScopeAsync(group.Key, null)));
             return(countriesByProposal
                    .SelectMany(batch => batch)
                    .ToDictionary(c => Tuple.Create(c.ProposalId, c.CountryId)));
         }
             );
         return(loader.LoadAsync(Tuple.Create(context.Source.ProposalId, context.Source.CountryId)));
     }
                   );
     Field <HrCountryScopeSchemaType, HrCountryScopeViewModel>()
     .Name("hrScope")
     .ResolveAsync(context => {
         var loader = accessor.Context.GetOrAddBatchLoader <Tuple <int, int>, HrCountryScopeViewModel>(
             "GetHrCountryScopes",
             async keys =>
         {
             var countriesByProposal = await Task.WhenAll(keys
                                                          .GroupBy(key => key.Item1)
                                                          .Select(group => client.HrScope_GetCountryScopeAsync(group.Key, null)));
             return(countriesByProposal
                    .SelectMany(batch => batch)
                    .ToDictionary(c => Tuple.Create(c.ProposalId, c.CountryId)));
         }
             );
         return(loader.LoadAsync(Tuple.Create(context.Source.ProposalId, context.Source.CountryId)));
     }
                   );
 }
Пример #5
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
                );
        }
Пример #6
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));
            }
                );
        }
Пример #7
0
 partial void Extend(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
 {
 }
Пример #8
0
 public UpdateProposalCountriesSchemaType(ProposingClient client, ReferenceDataCache cache, IDataLoaderContextAccessor accessor)
 {
     Name = "UpdateProposalCountries";
     Field(x => x.Countries, nullable: true, type: typeof(ListGraphType <ProposalCountryInputSchemaType>));
     this.Extend(client, cache, accessor);
 }
Пример #9
0
        private async Task Load(ProposingClient proposingClient)
        {
            var models = await proposingClient.ProductModels_GetAllProductModelsAsync();

            this.ProductModels = models.ToDictionary(m => m.Id);
        }
Пример #10
0
 public ReferenceDataCache(ProposingClient client)
 {
     //todo: need to support async factory method in container
     Load(client);
 }