Пример #1
0
        public NHLStatsQuery(IPlayerRepository playerRepository, ISkaterStatisticRepository skaterStatisticRepository)
        {
            Field <PlayerType>(
                "player",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context => playerRepository.Get(context.GetArgument <int>("id")));

            Field <PlayerType>(
                "randomPlayer",
                resolve: context => playerRepository.GetRandom());

            Field <ListGraphType <PlayerType> >(
                "players",
                resolve: context => playerRepository.All());


            Field <ListGraphType <LeagueType> >(
                "leagues",
                resolve: context => skaterStatisticRepository.GetAllLeagues());

            Field <ListGraphType <TeamType> >("teams",
                                              resolve: context => skaterStatisticRepository.GetAllTeams());

            Field <ListGraphType <SeasonType> >("seasons",
                                                resolve: context => skaterStatisticRepository.GetAllSeasons());
        }
Пример #2
0
 public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
 {
     Field(x => x.Id);
     Field(x => x.Name, true);
     Field(x => x.BirthPlace);
     Field(x => x.Height);
     Field(x => x.WeightLbs);
     Field <StringGraphType>("birthDate", resolve: context => context.Source.BirthDate.ToShortDateString());
     // Field<ListGraphType<SkaterStatisticType>>("skaterSeasonStats",
     //     arguments: new QueryArguments(new QueryArgument<IntGraphType> { Name = "id" }),
     //     resolve: context => skaterStatisticRepository.Get(context.Source.Id), description: "Player's skater stats");
     Field <ListGraphType <SkaterStatisticType> >("skaterSeasonStats",
                                                  arguments: new QueryArguments(
                                                      new QueryArgument <IntGraphType> {
         Name = "limit"
     },
                                                      new QueryArgument <IntGraphType> {
         Name = "offset"
     },
                                                      new QueryArgument <BooleanGraphType> {
         Name = "sort"
     }
                                                      ),
                                                  resolve: context => {
         var limit  = context.GetArgument <int?>("limit");
         var offset = context.GetArgument <int?>("offset");
         var sort   = context.GetArgument <bool?>("sort");
         return(skaterStatisticRepository.Get(context.Source.Id, limit, offset, sort));
     }
                                                  , description: "Player's skater stats");
 }
Пример #3
0
        public NHLStatsMutation(IPlayerRepository playerRepository, ISkaterStatisticRepository skaterRepository, ILogger <NHLStatsMutation> logging)
        {
            Name = "PlayerStatMutation";

            Field <PlayerType>(
                "createPlayer",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <PlayerInputType> > {
                Name = "player"
            },
                    new QueryArgument <ListGraphType <SkaterStatisticInputType> > {
                Name = "skaterStats"
            }
                    ),
                resolve: context =>
            {
                var player      = context.GetArgument <Player>("player");
                var skaterStats = context.GetArgument <List <SkaterStatistic> >("skaterStats");
                return(playerRepository.AddWithSkaterStats(player, skaterStats));
            });

            Field <StatusResultType>(
                "deletePlayer",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "playerId"
            }
                    ),
                resolve: context =>
            {
                var playerId = context.GetArgument <int>("playerId");
                return(playerRepository.Delete(playerId));
            });
        }
Пример #4
0
 public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
 {
     Field(x => x.Id);
     Field(x => x.Name, true);
     Field(x => x.BirthPlace);
     Field(x => x.Height);
     Field(x => x.WeightLbs);
     Field <StringGraphType>("birthDate", resolve: context => context.Source.BirthDate.ToShortDateString());
     Field <ListGraphType <SkaterStatisticType> >("skaterSeasonStats",
                                                  arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "id"
     }),
                                                  resolve: context => skaterStatisticRepository.Get(context.Source.Id), description: "Player's skater stats");
 }
Пример #5
0
        public PlayerType(ISkaterStatisticRepository skaterStatisticRepository)
        {
            Field(x => x.Id);
            Field(x => x.Name, true);
            Field(x => x.BirthPlace, true);
            Field(x => x.Height, true);
            Field(x => x.WeightLbs, true);
//            Field<StringGraphType>("birthDate", resolve: context => context.Source.BirthDate.ToString());
            Field <StringGraphType>("birthDate",
                                    resolve: context =>
                                    TimeZoneInfo.ConvertTimeFromUtc(context.Source.BirthDate, TimeZoneInfo.Local).ToString());
            Field <ListGraphType <SkaterStatisticType> >("skaterSeasonStats",
                                                         arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                                                         resolve: context => skaterStatisticRepository.Get(context.Source.Id),
                                                         description: "Player's skater stats");
        }
Пример #6
0
 public DataController(IPlayerRepository playerRepository, ISkaterStatisticRepository skaterStatistic)
 {
     _playerRepo = playerRepository;
     _skaterRepo = skaterStatistic;
 }