Beispiel #1
0
        private void CreateTournamentButton_Click(object sender, EventArgs e)
        {
            if (ValidateTournamentInfo())
            {
                TournamentModel tm = new TournamentModel
                {
                    TournamentName = tournamentNameValue.Text,
                    EntryFee       = decimal.Parse(entryFeeValue.Text),
                    EnteredTeams   = tournamentPlayersListBox.Items.Cast <TeamModel>().ToList(),
                    Prizes         = prizesListBox.Items.Cast <PrizeModel>().ToList()
                };
                TournamentLogic.CreateRounds(tm);

                GlobalConfig.Connections.CreateTournament(tm); // add tm to the database

                TournamentLogic.AlertUsersToNewRound(tm);      // alert users of first round matchups

                // Show the tournament that was just created
                TournamentViewerForm viewerForm = new TournamentViewerForm(tm);
                viewerForm.Show();

                this.Close();
            }
            else
            {
                MessageBox.Show("You have invalid tournament information. Please check and try again.",
                                "Error: Invalid Tournament", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }