public void CompareMainTitlesWithQuickNavigationTitles() { var quickNavigationMainTitles = NavigationMainTitles.Select(t => t.Text).ToList(); var mainTitles = MainHeaders.Select(t => t.Text).ToList(); AssertComparisonBothTitles(quickNavigationMainTitles, mainTitles); }
public TeamMatchesAdapter(IEnumerable <Team> teams, IEnumerable <Match> matches, IEnumerable <League> leagues, int teamId) { foreach (var league in leagues) { ListItems.Add(new ListItem { Index = MainHeaders.Count, Type = 0 }); MainHeaders.Add(new HeaderModel { Title = league.Name }); foreach (var match in matches.Where(m => m.LeagueId == league.Id).OrderBy(m => m.Date)) { ListItems.Add(new ListItem { Index = SubHeaders.Count, Type = 1 }); SubHeaders.Add(new HeaderModel { Title = match.Round.ToString() + ". forduló" }); ListItems.Add(new ListItem { Index = Contents.Count, Type = 2 }); if (teamId == match.HomeTeamId) { Contents.Add(new MatchResultModel { HomeTeam = teams.Where(t => t.Id == match.HomeTeamId).First().Name + " ", HomeScore = match.ScoreH.ToString(), AwayTeam = teams.Where(t => t.Id == match.AwayTeamId).First().Name, AwayScore = match.ScoreA.ToString(), Id = match.Id }); } else { Contents.Add(new MatchResultModel { AwayTeam = teams.Where(t => t.Id == match.HomeTeamId).First().Name + " ", AwayScore = match.ScoreH.ToString(), HomeTeam = teams.Where(t => t.Id == match.AwayTeamId).First().Name, HomeScore = match.ScoreA.ToString(), Id = match.Id }); } } } }
public LeagueMatchesAdapter(IEnumerable <Team> teams, IEnumerable <Match> matches, int rounds) { for (int i = 0; i < rounds; i++) { ListItems.Add(new ListItem { Index = MainHeaders.Count, Type = 0 }); MainHeaders.Add(new HeaderModel { Title = (i + 1) + ". forduló" }); List <Match> matchesInRound = matches.Where(m => m.Round == i + 1).OrderBy(m => m.Date).ThenBy(m => m.Time).ToList(); int j = 0; while (j < matchesInRound.Count) { ListItems.Add(new ListItem { Index = SubHeaders.Count, Type = 1 }); SubHeaders.Add(new HeaderModel { Title = matchesInRound.ElementAt(j).Date.ToString() }); int k = j; while (k < matchesInRound.Count && matchesInRound.ElementAt(j).Date == matchesInRound.ElementAt(k).Date&& matchesInRound.ElementAt(j).Time == matchesInRound.ElementAt(k).Time) { ListItems.Add(new ListItem { Index = Contents.Count, Type = 2 }); Contents.Add(new MatchResultModel { HomeTeam = teams.Where(t => t.Id == matchesInRound.ElementAt(k).HomeTeamId).First().Name + " ", HomeScore = matchesInRound.ElementAt(j).ScoreH.ToString(), AwayTeam = teams.Where(t => t.Id == matchesInRound.ElementAt(k).AwayTeamId).First().Name, AwayScore = matchesInRound.ElementAt(j).ScoreA.ToString(), Id = matchesInRound.ElementAt(j).Id }); k++; } j = k; } } }
private void Init(string title, string noMatchString, IEnumerable <Match> matches) { ListItems.Add(new ListItem { Index = MainHeaders.Count, Type = 0 }); MainHeaders.Add(new HeaderModel { Title = title }); int i = 0; if (matches.Count() == 0) { ListItems.Add(new ListItem { Index = Contents.Count, Type = 3 }); Contents.Add(new LiveMatchModelBase { Text = noMatchString }); } while (i < matches.Count()) { Match actualMatch = matches.ElementAt(i); League actualLeague = Leagues.First(l => l.Id == actualMatch.LeagueId); ListItems.Add(new ListItem { Index = SubHeaders.Count, Type = 1 }); SubHeaders.Add(new HeaderModel { Title = actualLeague.Name, Country = actualLeague.Country }); int j = i; //While in the same league while (j < matches.Count() && matches.ElementAt(j).LeagueId == actualMatch.LeagueId) { Team homeTeam = Teams.First(t => t.Id == actualMatch.HomeTeamId); Team awayTeam = Teams.First(t => t.Id == actualMatch.AwayTeamId); ListItems.Add(new ListItem { Index = Contents.Count, Type = 2 }); Contents.Add(new LiveMatchModel { Date = actualMatch.Date, Time = actualMatch.Time, HomeTeam = homeTeam.Name, AwayTeam = awayTeam.Name, HomeScore = actualMatch.ScoreH, AwayScore = actualMatch.ScoreA, MatchId = actualMatch.Id, State = actualMatch.State }); actualMatch = matches.ElementAt(j); j++; } i = j; } }