public ContestantList DeepCopy()
        {
            ContestantList contestantList = new ContestantList();

            foreach (var c in this)
            {
                contestantList.Add(new Contestant(c.ID, c.FirstName, c.LastName, c.Age, c.Email, c.Gender, c.SocialSecurityNr, c.Address, c.DiveLists.ToList()));
            }

            return(contestantList);
        }
        /// <summary>
        /// Add a new subcontest to the contest
        /// </summary>
        private void AddSubContest()
        {
            bool isDataValid = false;

            if (CheckDataInput.StringCheckFormat(View.TextBoxName.Text))
            {
                if (SubContestContestants.Count != 0)
                {
                    isDataValid = true;
                }
                else
                {
                    MessageBox.Show("En deltävling behöver minst en deltagare.");
                }
            }
            else
            {
                MessageBox.Show("Tävlingsnamn ej korrekt. Får ej innehålla specialtecken, förutom _ och -");
            }

            if (isDataValid)
            {
                // Make a copy of the gathered SubContestants
                List <Contestant> list           = SubContestContestants.ToList();
                ContestantList    contestantList = new ContestantList();
                foreach (var c in list)
                {
                    contestantList.Add(c);
                }

                // Create the subcontest
                SubContestBranch subContestBranch = new SubContestBranch(View.TextBoxName.Text, CurrentContest, contestantList);

                SubContests.Add(subContestBranch);
                View.ListViewSubContests.Items.Add(subContestBranch.Name);

                // clear the inputs
                SubContestContestants.Clear();
                ClearInputs();
            }
        }
Exemplo n.º 3
0
        public ContestantList FetchContestants()
        {
            DataTable contestantDataTable = FetchSpecifiedRole("contestant");

            // Iterate through data table and add too person list
            ContestantList contestantList = new ContestantList();

            foreach (DataRow row in contestantDataTable.Rows)
            {
                Contestant contestant = new Contestant
                {
                    ID        = Int32.Parse(row["id"].ToString()),
                    FirstName = row["firstName"].ToString(),
                    LastName  = row["lastName"].ToString(),
                    Age       = Int32.Parse(row["age"].ToString()),
                    Gender    = row["gender"].ToString(),
                    Email     = row["email"].ToString()
                };

                contestantList.Add(contestant);
            }

            return(contestantList);
        }