// MATCHES private void SetMatches() { SetMatchesDays(); var matches = AllMatches?.OrderBy(x => x.MatchTypeID).ThenBy(x => x.Time).Where(x => x.Time?.Date == MatchesDaySelected.Date); var matchesGroupList = new ObservableCollection <IGrouping <string, Match> >(matches?.GroupBy(x => x.MatchTypeName)); MatchesGroupList = matchesGroupList; }
// FIXTURES private void SetFixtures() { var fixturesCompetitions = new ObservableCollection <string>(); var fromDate = DateTime.Now.Date.AddDays(0); var toDate = DateTime.Now.Date.AddDays(360); var fixturesMatches = AllMatches?.OrderBy(x => x.MatchTypeID).ThenBy(x => x.Time).Where(x => x.Time > fromDate && x.Time < toDate && (x.StatusID < 12) || x.StatusID == 14) ?? new ObservableCollection <Match>(); foreach (IGrouping <string, Match> competitionMatches in fixturesMatches?.GroupBy(x => x.MatchTypeName)) { if (!string.IsNullOrEmpty(competitionMatches.Key)) { fixturesCompetitions.Add(competitionMatches.Key); } } FixturesCompetitions = new ObservableCollection <string>(fixturesCompetitions); if (string.IsNullOrEmpty(FixturesCompetitionSelected) && FixturesCompetitions.Count > 0) { FixturesCompetitionSelected = FixturesCompetitions.FirstOrDefault(); } var fixturesGroupList = fixturesMatches?.Where(x => x.MatchTypeName == FixturesCompetitionSelected).GroupBy(x => x.MatchTypeName); FixturesGroupList = new ObservableCollection <IGrouping <string, Match> >(fixturesGroupList); }
// RESULTS private void SetResults() { var resultsCompetitions = new ObservableCollection <string>(); var toDate = DateTime.Now.Date.AddDays(0); var fromDate = new DateTime(toDate.Year - 1, 12, 31); var resultsMatches = AllMatches?.OrderBy(x => x.MatchTypeID).ThenByDescending(x => x.Time).Where(x => x.Time > fromDate && x.Time < toDate || (x.StatusID == 13 || x.StatusID == 12)) ?? new ObservableCollection <Match>(); foreach (IGrouping <string, Match> competitionMatches in resultsMatches.GroupBy(x => x.MatchTypeName)) { if (!string.IsNullOrEmpty(competitionMatches.Key)) { resultsCompetitions.Add(competitionMatches.Key); } } ResultsCompetitions = new ObservableCollection <string>(resultsCompetitions); if (string.IsNullOrEmpty(ResultsCompetitionSelected) && ResultsCompetitions.Count > 0) { ResultsCompetitionSelected = ResultsCompetitions.FirstOrDefault(); } var resultsGroupList = resultsMatches?.Where(x => x.MatchTypeName == ResultsCompetitionSelected).GroupBy(x => x.MatchTypeName); ResultsGroupList = new ObservableCollection <IGrouping <string, Match> >(resultsGroupList); }