Example #1
0
        public IEnumerable <Standing> GetFromClientStandings(ExternalLeagueCode externalLeagueCode)
        {
            IEnumerable <Standing> result = null;
            var idSeason = GetIdSeason(externalLeagueCode);

            if (idSeason > 0)
            {
                StandingsResponse leagueTableResult;
                try
                {
                    //leagueTableResult = await _competitionResultSingleton.FootballDataOrgApiGateway.GetLeagueTableResultAsync(idSeason);
                    leagueTableResult = _competitionResultSingleton.FootballDataOrgApiGateway.GetLeagueTableResult(idSeason);
                }
                catch (AggregateException ex)
                {
                    LogAggregateException(ex);
                    leagueTableResult = new StandingsResponse {
                        Standing = new List <FootballDataOrg.ResponseEntities.Standing> {
                            new FootballDataOrg.ResponseEntities.Standing {
                                TeamName = EntityConstants.PotentialTimeout
                            }
                        }
                    };
                }
                if (leagueTableResult != null)
                {
                    result = GetResultMatchStandings(leagueTableResult);
                }
            }
            return(result);
        }
 public static LeaderboardStandingsResponse ToContract(this StandingsResponse standingsCore)
 {
     return(new LeaderboardStandingsResponse
     {
         ActorId = standingsCore.ActorId,
         ActorName = standingsCore.ActorName,
         Value = standingsCore.Value,
         Ranking = standingsCore.Ranking
     });
 }
Example #3
0
 private static IEnumerable <Standing> GetResultMatchStandings(StandingsResponse leagueTableResult)
 {
     if (!string.IsNullOrEmpty(leagueTableResult?.Error))
     {
         return(new List <Standing>
         {
             new Standing
             {
                 Team = leagueTableResult.Error
             }
         });
     }
     else
     {
         return(leagueTableResult?.Standing?.Select(x => new Standing
         {
             Against = x.GoalsAgainst,
             AwayDraws = x.Away?.Draws ?? -1,
             AwayGoalsAgainst = x.Away?.GoalsAgainst ?? -1,
             AwayGoalsFor = x.Away?.Goals ?? -1,
             AwayLosses = x.Away?.Losses ?? -1,
             AwayWins = x.Away?.Wins ?? -1,
             //CrestURI = x.CrestURI,
             Diff = x.GoalDifference,
             For = x.Goals,
             HomeDraws = x.Home?.Draws ?? -1,
             HomeGoalsAgainst = x.Home?.GoalsAgainst ?? -1,
             HomeGoalsFor = x.Home?.Goals ?? -1,
             HomeLosses = x.Home?.Losses ?? -1,
             HomeWins = x.Home?.Wins ?? -1,
             Played = x.PlayedGames,
             Points = x.Points,
             Rank = x.Position,//full
             //Rank = x.Rank,//minified
             //Team = MapperHelper.MapExternalTeamNameToInternalTeamName(x.Team),//minified
             Team = MapperHelper.MapExternalTeamNameToInternalTeamName(x.TeamName),//full
         }));
     }
 }
Example #4
0
        public static IEnumerable <TablePosition> AsTablePositions(this StandingsResponse response)
        {
            var standingDtos = response.Standings;

            return(standingDtos.First().Table.Select(dto => new TablePosition
            {
                Id = dto.Position,
                CurrentMatchday = response.Season.CurrentMatchday,
                UpdatedAt = DateTime.UtcNow,
                Team = dto.Team,
                TeamStatistics = new TeamStatistics
                {
                    PlayedGames = dto.PlayedGames,
                    Won = dto.Won,
                    Draw = dto.Draw,
                    Lost = dto.Lost,
                    Points = dto.Points,
                    GoalsFor = dto.GoalsFor,
                    GoalsAgainst = dto.GoalsAgainst,
                    GoalDifference = dto.GoalDifference
                }
            }));
        }