コード例 #1
0
        public AppQuery(ILoggerFactory loggerFactory, IQuestionService questionService,
                        IFitnessPlanService fitnessPlanService)
        {
            var logger = loggerFactory.CreateLogger <AppQuery>();

            Field <QuestionPayload>()
            .Name("questionByIndex")
            .Argument <IntGraphType>("index", "The index of the question to get, 0 by default")
            .Resolve(c => {
                var index = c.GetArgument <int?>("index");

                if (!index.HasValue)
                {
                    index = 0;
                }

                return(questionService.GetNextQuestion(index.Value));
            });

            Field <ListGraphType <FitnessPlanPayload> >()
            .Name("fitnessPlans")
            .Argument <FitnessPlanOrderInput>("order", "The ordering for the fitness plans")
            .Resolve(c => {
                var fitnessPlanOrder = c.GetArgument <PlanOrder>("order");
                var fitnessPlans     = fitnessPlanService.GetAll();

                if (fitnessPlanOrder?.PlanIds == null)
                {
                    return(fitnessPlans);
                }

                return(fitnessPlans.ToList().OrderBy(x => fitnessPlanOrder.PlanIds.IndexOf(x.Id)));
            });
        }
コード例 #2
0
 public QuestionService(IRepository <Question> repository, IFitnessPlanService fitnessPlanService,
                        IVariationPlanService variationPlanService)
 {
     _repository           = repository;
     _fitnessPlanService   = fitnessPlanService;
     _variationPlanService = variationPlanService;
 }
コード例 #3
0
        public static async Task <IWebHost> SeedData(this IWebHost webHost)
        {
            using (var scope = webHost.Services.GetService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>())
                {
                    _answerService      = scope.ServiceProvider.GetRequiredService <IAnswerService>();
                    _questionService    = scope.ServiceProvider.GetRequiredService <IQuestionService>();
                    _fitnessPlanService = scope.ServiceProvider.GetRequiredService <IFitnessPlanService>();

                    context.Database.Migrate();

                    SeedFitnessPlans();
                    SeedQandA();
                }
            }

            return(webHost);
        }
コード例 #4
0
        public FitnessPlanPayload(IFitnessPlanService fitnessPlanService)
        {
            _fitnessPlanService = fitnessPlanService;

            Name = nameof(FitnessPlan);

            Id(x => x.Id);
            Field(x => x.Name, nullable: true);
            Field(x => x.Description, nullable: true);
            Field(x => x.Link, nullable: true);
            Field(x => x.DaysPerWeek);
            Field <TimeToWorkoutPayload>("timeToWorkout", "The time the workout takes in hours/minutes", resolve: x =>
            {
                return(new TimeToWorkout
                {
                    Hours = x.Source.TimeToCompleteWorkout?.Hours,
                    Minutes = x.Source.TimeToCompleteWorkout?.Minutes,
                });
            });
            Field <FitnessPlanPayload>("parentFitnessPlan", "The fitness plan that this variation plan is related to.");
            Field <ListGraphType <FitnessPlanPayload> >("variationPlans", "The different types of variations of this fitness plan.");
        }
コード例 #5
0
        public FitnessPlanPayload(IFitnessPlanService fitnessPlanService)
        {
            _fitnessPlanService = fitnessPlanService;

            Name = nameof(FitnessPlan);

            Id("planId", x => x.Id);
            Field(x => x.Name);
            Field(x => x.Description);
            Field <ListGraphType <LinkPayload> >("links", "The resources for this fitness plan, e.g. apps, workouts etc");
            Field <ListGraphType <IntGraphType> >("workoutDaysPerWeek", "The days per week to workout for this fitness plan", resolve: x => x.Source.WorkoutDaysPerWeek.Select(z => z.DaysPerWeek));
            Field <TimeToWorkoutPayload>("timeToWorkout", "The time the workout takes in hours/minutes", resolve: x =>
            {
                return(new TimeToWorkout
                {
                    Hours = x.Source.TimeToCompleteWorkout.Hours,
                    Minutes = x.Source.TimeToCompleteWorkout.Minutes,
                });
            });
            Field <ListGraphType <VariationPlanPayload> >("variationPlans", "The different types of variations of this fitness plan.");
            Interface <PlanInterface>();
        }
コード例 #6
0
 public AppController(IFitnessPlanService fitnessPlanService)
 {
     _fitnessPlanService = fitnessPlanService;
 }
コード例 #7
0
 public QuestionService(IRepository <Question> repository, IFitnessPlanService fitnessPlanService)
 {
     _repository         = repository;
     _fitnessPlanService = fitnessPlanService;
 }