예제 #1
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                Workout = await WorkoutService.GetWorkoutByIdAsync(WorkoutId);

                ExerciseOptions = await ExerciseService.GetExercisesAsync();

                MuscleGroups = await MuscleGroupService.GetMuscleGroupsAsync();

                WorkoutExercises = Workout.WorkoutExercises.OrderBy(we => we.OrderInt).ToList();
            }
            catch (Exception)
            {
                Message = "Workout not found!";
            }
        }
예제 #2
0
        public SchemaQuery(ExerciseService exercises, TrainingScheduleService trainingScheduleService, WorkshopService workshopService, WorkoutService workoutService, JourneyService journeyService)
        {
            Name = "Query";
            Field <ListGraphType <ExerciseType> >(
                "exercises",
                resolve: context => exercises.GetExercisesAsync()
                );

            Field <ListGraphType <TrainingScheduleType> >(
                "trainingSchedules",
                resolve: context => trainingScheduleService.GetTrainingSchedulesAsync()
                );

            Field <ListGraphType <WorkshopType> >(
                "workshops",
                resolve: context => workshopService.GetWorkshopsAsync()
                );

            Field <ListGraphType <WorkoutType> >(
                "workouts",
                resolve: context => workoutService.GetWorkoutsAsync()
                );

            Field <ListGraphType <JourneyType> >(
                "journeys",
                resolve: context => journeyService.GetJourneysAsync()
                );


            FieldAsync <ExerciseType>(
                "exercise",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: async context => {
                return(await context.TryAsyncResolve(
                           async c => await exercises.GetExerciseByIdAsync(c.GetArgument <int>("id"))
                           ));
            }
                );


            FieldAsync <JourneyType>(
                "journey",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: async context => {
                return(await context.TryAsyncResolve(
                           async c => await journeyService.GetJourneyByIdAsync(c.GetArgument <int>("id"))
                           ));
            }
                );

            FieldAsync <WorkoutType>(
                "workout",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: async context => {
                return(await context.TryAsyncResolve(
                           async c => await workoutService.GetWorkoutAsync(c.GetArgument <int>("id"))
                           ));
            }
                );
        }