/// <summary> /// fuction is created for the update of the tournaments rounds after completing each rounds. /// </summary> /// <param name="model"></param> public static void UpdateTournamentResults(TournamentModel model) { int startingRound = model.CheckCurrentRound(); 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.CheckCurrentRound(); if (endingRound > startingRound) { // alert users //EmailLogic.SendEmail(); model.AlertUsersToNewRound(); } }
public static void AlertUsersToNewRound(this TournamentModel 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()); } } } }