Beispiel #1
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);
                    }
                }
            }

            MarkWinnerInMatchups(toScore);
            AdvancedWinners(toScore, model);

            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x)); //some as the foreach below

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

            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                model.AlertUsersToNewRound();
            }
        }
Beispiel #2
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();
            }
        }
        /// <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();
            }
        }
        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();
            }
        }
        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)
                {
                    //byes don't get their own matchup entry(entries count in round is one)
                    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();
            }
        }
Beispiel #7
0
        public static void UpdateResults(TournamentModel tournament)
        {
            int startingRound = tournament.CheckCurrRound();

            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);
                    }
                }
            }

            MarkWinner(toScore);
            AdvanceWinners(toScore, tournament);
            toScore.ForEach(x => GlobalConfig.Connection.UpdateMatchup(x));

            int endingRound = tournament.CheckCurrRound();

            if (endingRound > startingRound)
            {
                tournament.AlertUsersToNewRound();
            }
        }
Beispiel #8
0
        public static void UpdateTournamentResults(TournamentModel model)
        {
            int startingRound = model.checkCurrentRound();

            List <MatchupModel> toScore = new List <MatchupModel>();

            model.Rounds.ForEach(round =>
            {
                round.ForEach(rm =>
                {
                    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();
            }
        }
Beispiel #9
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();
            }
        }
Beispiel #12
0
        public static void UpdateTournamentResults(TournamentModel tournament, MatchupModel matchupToUpdate)
        {
            int startingRound = GetCurrentRound(tournament);

            SetMatchupWinner(matchupToUpdate);
            GlobalConfig.Connections.UpdateMatchup(matchupToUpdate);

            AdvanceWinner(matchupToUpdate, tournament);

            int endingRound = GetCurrentRound(tournament);

            if (endingRound > tournament.Rounds.Count)
            {
                // last round is finished
                CompleteTournament(tournament);
            }
            else 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)
                {
                    //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();
            }
        }