public async Task <List <ScheduledMatchDto> > GetMatches(RequestDto request) { //TODO: Refactor //Convert the list of selected list to the string of filter var codes = GetCompetitionsCodes(request.LeaguesChecked); var matchProvider = MatchProvider.Create().With(_httpClient).Build(); var matches = await matchProvider.GetAllMatches("competitions", codes, "dateFrom", request.StartingDate.ToString("yyyy-MM-dd"), "dateTo", request.EndingDate.ToString("yyyy-MM-dd")); var result = new List <ScheduledMatchDto>(); foreach (var match in matches) { Enum.TryParse(match.Status.ToUpper(), out Status state); ScoreResult scoreResult = new ScoreResult(match.Score.FullTime.HomeTeam, match.Score.FullTime.AwayTeam); result.Add(new ScheduledMatchDto( match.HomeTeam.Name, match.AwayTeam.Name, match.UtcDate, state, scoreResult, (int)match.Matchday, new LeagueDto(match.Competition.Name, match.Competition.Area.Name) )); } //Filter matches with selected status result = result.Where(m => request.StatusChecked.Contains(m.Status)).ToList(); return(result); }
public static void Main(string[] args) { var httpClient = new HttpClient(); var apiKey = Environment.GetEnvironmentVariable("ApiKey"); if (!string.IsNullOrEmpty(apiKey)) { httpClient.DefaultRequestHeaders.Add("X-Auth-Token", apiKey); } var competitionController = CompetitionProvider.Create() .With(httpClient) .Build(); var matchController = MatchProvider.Create() .With(httpClient) .Build(); //GetCompetitions(competitionController); //GetCompetitionsWithFilter(competitionController); //GetCompetitionById(competitionController, 2019); //GetAllMatchOfCompetition(matchController, 2019); //GetAllMatch(matchController); GetMatchById(matchController, 200033); Console.ReadKey(); }