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);
                    }
                }
            }
            MarkWinnersInMatchups(toScore);

            AdvanceWinners(toScore, model);

            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));
            int endingRound = model.CheckCurrentRound();

            /*
             * if (endingRound > startingRound)
             * {
             *  model.AlertUsersToNewRound();
             *
             * }
             */
        }
        /// <summary>
        /// Update matchup scores and send emails if new round is starting
        /// </summary>
        /// <param name="tournament">Tournament information.</param>
        public static void UpdateTournamentResults(TournamentModel tournament)
        {
            int startingRound = tournament.CheckCurrentRound();
            // Matchups that need updating of score
            List <MatchupModel> toScore = new List <MatchupModel>();

            foreach (List <MatchupModel> round in tournament.Rounds)
            {
                foreach (MatchupModel roundMatchup in round)
                {
                    // If winner is not null, that means that match has already been played out, so the score was set
                    // If both entries have score 0 that means that their score is not set yet => no need for updateing score
                    // Matchup with 1 entry is match with bye, where team 1 automaticaly wins without needing to input score
                    if (roundMatchup.Winner == null && (roundMatchup.Entries.Any(x => x.Score != 0) || roundMatchup.Entries.Count == 1))
                    {
                        toScore.Add(roundMatchup);
                    }
                }
            }
            MarkWinnersInMatchups(toScore);

            AdvanceWinners(toScore, tournament);

            // Update every matchup who's score's been set
            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));

            // If there's been a round completed (all matchups in it were played out) alert winners of the new round start
            int endingRound = tournament.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                // Alert users
                tournament.AlertUsersToNewRound();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Represents the update of the tournaments with scores of played matches
        /// or the bye week
        /// And sends messages to users
        /// </summary>
        /// <param name="model">The tournament model</param>
        public static void UpdateTournamentResults(TournamentModel model)
        {
            int startingRound           = model.CheckCurrentRound();
            List <MatchupModel> toScore = new List <MatchupModel>();

            foreach (List <MatchupModel> rounds in model.Rounds)
            {
                foreach (MatchupModel rm in rounds)
                {
                    if (rm.Winner == null && (rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1))
                    {
                        toScore.Add(rm);
                    }
                }
            }

            markWinnerInMatchups(toScore);
            // TODO: Update the data source and get back the updated ID's from the datasource

            AdvanceWinners(toScore, model);

            // Update the data source
            // oneliner for a foreach
            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));

            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                // Email users
                model.AlertUsersToNewRound();
            }
        }
Esempio n. 4
0
        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);
                    }
                }
            }

            MarkWinnersInMatchups(toScore);
            AdvanceWinners(toScore, model);

            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));
            //Same as above
            //foreach(MatchupModel x in toScore)
            //{
            //    GlobalConfig.Connection.UpdateMatchup(x);
            //}

            int endingRound = model.CheckCurrentRound();

            //Email alert users of a new round
            if (startingRound < endingRound)
            {
                model.AlertUsersToNewRound();
            }
        }
        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);
                    }
                }
            }

            MarkWinnersInMatchups(toScore);

            AdvanceWinners(toScore, model);

            //GlobalConfig.Connection.UpdateMatchup(m); za svaki element u listi toScore
            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));
            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                //E-mail-uj korisnike
                //EmailLogic.SendEmail();

                model.AlertUsersToNewRound();
            }
        }
        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 a game winner has been decided we don't need to worry about this
                    // If a game winner has not been decided and either
                    // A team has a score or there's only one team in the game
                    if ((rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1))
                    {
                        // Add that team to a list of teams to be scored
                        toScore.Add(rm);
                    }
                }
            }

            MarkWinnerInMatchups(toScore);

            AdvanceWinners(toScore, model);

            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));

            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                model.AlertUsersToNewRound();
            }
        }
Esempio n. 7
0
        public static void UpdateTournamentResults(TournamentModel model)
        {
            int startingRound = model.CheckCurrentRound();

            List <MatchupModel> toScore = new List <MatchupModel>(); // Matchups need to be scored

            foreach (List <MatchupModel> round in model.Rounds)
            {
                foreach (MatchupModel rm in round)
                {
                    // If the matchup has not yet scored (so no winner yet) and there is a winner or a bye
                    if (rm.Winner == null && (rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1))
                    {
                        toScore.Add(rm); // Let score it!
                    }
                }
            }

            MarkWinnerInMatchups(toScore);

            AdvanceWinners(toScore, model);

            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));

            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                // A new round is started, with unplayed matchups, so emailing is needed to alert teams.
                model.AlertUsersToNewRound();
            }
        }
        public static void UpdateTournamentResults(TournamentModel tournament)
        {
            var startingRound = tournament.CheckCurrentRound();
            var toScore       = new List <MatchupModel>();

            foreach (var round in tournament.Rounds)
            {
                foreach (var roundMatch in round)
                {
                    if (roundMatch.Winner == null && (roundMatch.Entries.Any(x => x.Score != 0) || roundMatch.Entries.Count == 1))
                    {
                        toScore.Add(roundMatch);
                    }
                }
            }

            SetWinner(toScore);

            AdvanceBracketWinner(tournament, toScore);

            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));
            var endingRound = tournament.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                tournament.AlertUsersToNewRound();
            }
        }
        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) //Now we have each matchup
                {
                    //Check if any of the entries have a score not equal to zero. So if we have completed a matchthen we've put the value for two scores in
                    //We are not accepting ties for tournaments. Therefore one team at least has to have a score different than zero. They can be negative or positive.
                    //It just cant both be zero. So if any entry can say ".Score != 0", then it return TRUE. But if rm.Entries.Count == 1, then there is one team in match. There are bye
                    //rm.Winner == null - we have not yet assigned to winner
                    // WE WILL KNOW WHICH ONE NEED TO BE SCORED
                    if (rm.Winner == null && (rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1))
                    {
                        toScore.Add(rm); //добавился тот , у кого bye
                    }
                }
            }

            MarkWinnersInMatchups(toScore); //Если у нас в метче есть bye, то почеаем, что в этом метче есть победитель m.Winner = Entry []

            AdvancedWinners(toScore, model);

            //Shorten down foreach
            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));
            //its the same as if we write

            /*
             * foreach(MatchupModel x in toScore)
             * {
             *  GlobalConfig.Connection.UpdateMatchup(x);
             * }
             */

            //This is there EMAIL part starts

            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                //Alert users
                model.AlertUsersToNewRound();
            }
        }
        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)
                {
                    //rm.Entries.Count==1 chacks for byes entry in matchup
                    //rm.Entries.Any(x=>x.Score!=0 => we dont do ties in tourenamet there for one team at least have a score
                    // of score!=0 in a match up !
                    if (rm.Winner == null && (rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1))
                    {
                        toScore.Add(rm);
                    }
                }
            }

            MarkWinnewrsInMatchup(toScore);

            AdvancedWinners(toScore, model);

            //shorter code
            //foreach (var x in toScore)
            //{
            //    GlobalConfig.Connaction.UpadateMatchup(x));

            //}
            toScore.ForEach(x => GlobalConfig.Connaction.UpadateMatchup(x));
            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                model.AlertUsersToNewRound();
            }
        }
        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)
                {
                    // Check any entry has score not equals to 0

                    // Here want to update the bye team with winner to set itself, but
                    // when update the entry id is all 0, it is not good time to update it, so remove the check rm.Entries.Count == 1
                    //    if (rm.Winner == null && (rm.Entries.Any(x => x.Score != 0) || rm.Entries.Count == 1))

                    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 and send emails
                model.AlertUsersToNewRound();
            }
        }
Esempio n. 12
0
        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());
                    }
                }
            }
        }
        public static void AlertUsersToNewRound(this TournamentModel model)
        {
            int currentRoundNumber = model.CheckCurrentRound();
            // If the line below does not give you what you are looking for, you can do a foreach loop
            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());
                    }
                }
            }
        }
Esempio n. 14
0
        public static void AlertUsersToNewRound(this TournamentModel model)
        {
            var currentRoundCount = model.CheckCurrentRound();
            var currentRound      = model.Rounds.First(x => x.First().MatchupRound == currentRoundCount);

            foreach (var matchup in currentRound)
            {
                foreach (var me in matchup.Entries)
                {
                    foreach (var member in me.TeamCompeting.TeamMembers)
                    {
                        AlertPersonToNewRound(member,
                                              matchup.Entries.FirstOrDefault(x => x.TeamCompeting != me.TeamCompeting));
                    }
                }
            }
        }
        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 game in currentRound)
            {
                foreach (MatchupEntryModel team in game.Entries)
                {
                    foreach (PersonModel player in team.TeamCompeting.TeamMembers)
                    {
                        MatchupEntryModel competingTeam = game.Entries.Where(x => x.TeamCompeting != team.TeamCompeting).FirstOrDefault();
                        AlertPlayerToNewRound(player, team.TeamCompeting.TeamName, competingTeam);
                    }
                }
            }
        }
Esempio n. 16
0
        public static void AlertUsersToNewRound(this TournamentModel model)
        {
            int currentRoundNumber = model.CheckCurrentRound();
            //List of list of matchups in round. We are pulling the current round
            List <MatchupModel> currentRound = model.Rounds.Where(x => x.First().MatchupRound == currentRoundNumber).First();

            //Each round has a matchup
            foreach (MatchupModel matchup in currentRound)
            {
                //Each matchup has 2 teams
                foreach (MatchupEntryModel me in matchup.Entries)
                {
                    //Each team member in the teams
                    foreach (PersonModel p in me.TeamCompeting.TeamMembers)
                    {
                        AlertPersonToNewRound(p, me.TeamCompeting.TeamName, matchup.Entries.Where(x => x.TeamCompeting != me.TeamCompeting).FirstOrDefault());
                    }
                }
            }
        }