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); }
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); }