//Method create model last matches private TeamCheckResult CreateListOfLastMatches(TeamCheckResult model, MatchesDTO matches) { var listOfResults = new List <MatchResult>(); int seriesWithoutDraw = 0; foreach (var match in matches.data.match) { var matchResult = new MatchResult() { Date = match.date, HomeTeam = match.home_name, Score = match.score, AwayTeam = match.away_name }; matchResult.IsDraw = CheckResult(matchResult.Score); listOfResults.Add(matchResult); if (matchResult.IsDraw == "NIE") { seriesWithoutDraw++; } else { seriesWithoutDraw = 0; } model.NoDrawSeries = seriesWithoutDraw; } model.MatchResults = listOfResults; return(model); }
//Method checks last 30 results (or less) from 2020-01-01 for team by competition. public async Task <TeamCheckResult> CheckTeam(string competitionId, string teamId) { var model = new TeamCheckResult(); //GET Method var _httpClient = _httpClientFactory.CreateClient("myAPIClient"); HttpResponseMessage responseMessage = await _httpClient.GetAsync(_httpClient.BaseAddress + "scores/history.json?key=" + _configuration["AuthenticationAPI:LIVESCORE_API_KEY"] + "&secret=" + _configuration["AuthenticationAPI:LIVESCORE_API_SECRET"] + "&from=2020-01-01&team=" + teamId + "&competition_id=" + competitionId); if (responseMessage.IsSuccessStatusCode) { string response = await responseMessage.Content.ReadAsStringAsync(); var matches = JsonConvert.DeserializeObject <MatchesDTO>(response); return(CreateListOfLastMatches(model, matches)); } return(null); }