Esempio n. 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);
                    }
                }
            }

            MarkWinnersInMatchups(toScore);

            AdvanceWinners(toScore, model);

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

            int endingRound = model.CheckCurrentRound();

            if (endingRound > startingRound)
            {
                model.AlertToNewRound();
            }
        }
        private void createTournamentButton_Click(object sender, EventArgs e)
        {
            // Validate data
            decimal fee           = 0;
            bool    feeAcceptable = decimal.TryParse(entryFeeValue.Text, out fee);

            if (!feeAcceptable)
            {
                MessageBox.Show("You need to enter a valid Entry Fee", "Invalid Fee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create tournament model
            TournamentModel tm = new TournamentModel();

            tm.TournamentName = tournamentNameValue.Text;
            tm.EntryFee       = fee;

            tm.Prizes       = selectedPrizes;
            tm.EnteredTeams = selectedTeams;

            TournamentLogic.CreateRounds(tm);

            // Create tournament entry
            // Create prizes entry
            // create all of the team entry
            GlobalConfig.Connection.CreateTournament(tm);

            tm.AlertToNewRound();

            TournamentViewerForm frm = new TournamentViewerForm(tm);

            frm.Show();
            this.Close();
        }