public static void UpdateTournamentResult(TournamnetModel model) { int startingRound = model.CheckCurrentRound(); List <MatchupModel> toScore = new List <MatchupModel>(); foreach (List <MatchupModel> round in model.Rounds) { foreach (MatchupModel rm in round) { //check if (any of the entries has a score not 0, or entries =1 (thats means we have a bye team)) // and we don't have a winner 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.CheckCurrentRound(); if (endingRound > startingRound) { model.AlertUsersToNewRound(); } }
public static void AlertUsersToNewRound(this TournamnetModel model) { int currentRoundNumber = model.CheckCurrentRound(); List <MatchupModel> currentRound = model.Rounds.Where(x => x.First().MatchupRound == currentRoundNumber).First(); foreach (MatchupModel matchup in currentRound) { 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()); } } } }