public static void UpdateTournamentResults(TournamentModel tournament) { int startingRound = tournament.GetCurrentRound(); 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); } } } MarkWinnersInMatchup(toScore); AdvanceWinners(toScore, tournament); toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x)); int endingRound = tournament.GetCurrentRound(); if (endingRound > startingRound) { tournament.AlertUsersToNextRound(); } }
public static void AlertUsersToNextRound(this TournamentModel tournament) { int currentRoundNumber = tournament.GetCurrentRound(); List <MatchupModel> currentRound = tournament.Rounds.Where(x => x.First().MatchupRound == currentRoundNumber).First(); foreach (MatchupModel m in currentRound) { foreach (MatchupEntryModel me in m.Entries) { foreach (PersonModel p in me.TeamCompeting.TeamMembers) { AlertPersonToNextRound(p, me.TeamCompeting.TeamName, m.Entries.Where(x => x.TeamCompeting != me.TeamCompeting).FirstOrDefault()); } } } }