Beispiel #1
0
        private async Task <List <TeamTableEntity> > GetTeamsFromSportsRadar()
        {
            var url  = string.Format(Keys.SportsRadar.TeamsUrlFormat, ApiKey);
            var json = await HttpClient.GetStringAsync(url);

            var radarTeams       = TeamsEntity.FromJson(json);
            var teamTableResults = radarTeams.ToTeamTableEntites().ToList();

            return(teamTableResults);
        }
Beispiel #2
0
        public static IEnumerable <TeamTableEntity> ToTeamTableEntites(this TeamsEntity teamsEntity)
        {
            var now = DateTimeOffset.UtcNow;

            foreach (var conference in teamsEntity.Conferences)
            {
                if (conference.Subdivisions.Count == 0)
                {
                    foreach (var team in conference.Teams)
                    {
                        yield return(new TeamTableEntity(conference.Id, team.Id)
                        {
                            Timestamp = now,
                            Market = team.Market,
                            Name = team.Name,
                            ConferenceName = conference.Name
                        });
                    }
                }
                else
                {
                    foreach (var subdivision in conference.Subdivisions)
                    {
                        foreach (var team in subdivision.Teams)
                        {
                            yield return(new TeamTableEntity(conference.Id, team.Id)
                            {
                                Timestamp = now,
                                Market = team.Market,
                                Name = team.Name,
                                ConferenceName = conference.Name
                            });
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public static string ToJson(this TeamsEntity self) => JsonConvert.SerializeObject(self, Converter.Settings);