コード例 #1
0
ファイル: NhlApiService.cs プロジェクト: simoneisner/hfi_api
        public NhlPlayerStatsContainer GetPlayerStats(int playerId)
        {
            NhlPlayerStatsContainer container = new NhlPlayerStatsContainer();
            string url = _externalApiRoot.AppendPathSegment("api").AppendPathSegment("v1")
                         .AppendPathSegment("people")
                         .AppendPathSegment(playerId)
                         .AppendPathSegment("stats")
                         .SetQueryParam("stats", "statsSingleSeason")
                         .SetQueryParam("season", _configuration.GetSection("CurrentSeason").Value);

            var client   = new RestClient(url);
            var response = client.Execute <NhlPlayerStatsContainer>(new RestRequest());

            container = JsonConvert.DeserializeObject <NhlPlayerStatsContainer>(response.Content);
            return(container);
        }
コード例 #2
0
ファイル: NhlApiService.cs プロジェクト: simoneisner/hfi_api
        public Player AssemblePlayer(NhlPlayer nhlPlayer)
        {
            Player player = new Player();

            player.nhlPlayer = nhlPlayer;
            player.nhlPlayerStatsContainer = new NhlPlayerStatsContainer();
            NhlPlayerStatsContainer container = GetPlayerStats(nhlPlayer.person.id);

            player.nhlPlayerStatsContainer = container;
            if (player.nhlPlayer.person.firstName == null)
            {
                NhlPerson person = new NhlPerson();
                string    url    = _externalApiRoot.AppendPathSegment("api").AppendPathSegment("v1")
                                   .AppendPathSegment("people")
                                   .AppendPathSegment(player.nhlPlayer.person.id);

                var client   = new RestClient(url);
                var response = client.Execute <NhlPersonContainer>(new RestRequest());
                person = JsonConvert.DeserializeObject <NhlPersonContainer>(response.Content).people[0];
                player.nhlPlayer.person = person;
            }
            //hfiPlayers.Add(player);
            return(player);
        }