public static void UpdateResults(TournamentModel tournament) { int startingRound = tournament.CheckCurrRound(); List <MatchupModel> toScore = new List <MatchupModel>(); foreach (List <MatchupModel> round in tournament.Rounds) { foreach (MatchupModel rm in round) { if (rm.Winner == null && (rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1)) { toScore.Add(rm); } } } MarkWinner(toScore); AdvanceWinners(toScore, tournament); toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x)); int endingRound = tournament.CheckCurrRound(); if (endingRound > startingRound) { tournament.AlertUsersToNewRound(); } }
public static void AlertUsersToNewRound(this TournamentModel model) { int currRoundNum = model.CheckCurrRound(); List <MatchupModel> currRound = model.Rounds.Where(x => x.First().MatchupRound == currRoundNum).First(); foreach (MatchupModel matchup in currRound) { foreach (MatchupEntryModel me in matchup.Entries) { foreach (PersonModel p in me.TeamCompeting.TeamMembers) { AlertPersonToNewRound(p, me.TeamCompeting.TeamName, matchup.Entries.Where(x => x.TeamCompeting != me.TeamCompeting).FirstOrDefault()); } } } }