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