예제 #1
0
        public TestMutation(IAccountService accountService, ICppiFloorService cppiFloorService)
        {
            Name = "TestMutation";

            Field <FloorChangeType>(
                "addFloorChange",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "accountId", Description = "The account id."
            },
                    new QueryArgument <FloatGraphType> {
                Name = "cashFlow", Description = "The cash flow."
            },
                    new QueryArgument <NonNullGraphType <FloorChangeReasonType> > {
                Name = "changeReason", Description = "Reason for change."
            }
                    ),
                resolve: context =>
            {
                var accountId    = context.GetArgument <int>("accountId");
                var cashFlow     = context.GetArgument <double?>("cashFlow");
                var changeReason = context.GetArgument <FloorChangeReason>("changeReason");
                return(cppiFloorService.AddFloorChangeAsync(accountId, cashFlow, changeReason));
            }
                );
        }
예제 #2
0
        public TestQuery(IAccountService accountService, ICppiFloorService cppiFloorService)
        {
            Name = "TestQuery";

            Field <AccountType>(
                "account",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "accountId", Description = "The account id."
            }
                    ),
                resolve: context =>
            {
                var accountId = context.GetArgument <int>("accountId");
                return(accountService.GetByAccountIdAsync(accountId));
            }
                );

            Field <BalanceType>(
                "balance",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "accountId", Description = "The account id."
            }
                    ),
                resolve: context =>
            {
                var accountId = context.GetArgument <int>("accountId");
                return(accountService.GetBalanceAsync(accountId));
            }
                );

            Field <RevenueType>(
                "revenue",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "accountId", Description = "The account id."
            }
                    ),
                resolve: context =>
            {
                var accountId = context.GetArgument <int>("accountId");
                return(accountService.GetRevenuePercentagesAsync(accountId));
            }
                );

            Field <QuarterlyRevenueType>(
                "quarterlyRevenue",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "accountId", Description = "The account id."
            }
                    ),
                resolve: context =>
            {
                var accountId = context.GetArgument <int>("accountId");
                return(accountService.GetQuarterlyRevenueAsync(accountId));
            }
                );

            Field <ListGraphType <FloorChangeType> >(
                "floorHistory",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "accountId", Description = "The account id."
            }
                    ),
                resolve: context =>
            {
                var accountId = context.GetArgument <int>("accountId");
                return(cppiFloorService.SelectHistoryByAccountAsync(accountId));
            }
                );
        }