Esempio n. 1
0
        /// <summary>
        /// Add a judge from the DB to the contest
        /// </summary>
        public void AddJudgeToContest()
        {
            try
            {
                // Collect the chosen judge
                var judgeFirstName = View.ListViewGlobalJudges.SelectedItems[0].SubItems[0].Text;

                var  judgeLastName = View.ListViewGlobalJudges.SelectedItems[0].SubItems[1].Text;
                bool isAdded       = false;

                // Check if judge is already added to the contest
                foreach (var j in ContestJudgeList)
                {
                    if (String.Equals(j.FirstName, judgeFirstName) && String.Equals(j.LastName, judgeLastName))
                    {
                        isAdded = true;
                        MessageBox.Show("Domare är redan tillagd!");
                        break;
                    }
                }

                // Collect the correct Judge object
                Judge judgeToBeAdded = null;

                if (!isAdded)
                {
                    foreach (var j in GlobalJudgeList)
                    {
                        if (String.Equals(j.FirstName, judgeFirstName) && String.Equals(j.LastName, judgeLastName))
                        {
                            judgeToBeAdded = j;
                        }
                    }

                    if (judgeToBeAdded != null)
                    {
                        ContestJudgeList.Add(judgeToBeAdded);
                    }
                }

                UpdateListViews();
            }

            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Välj en domare!");
            }
        }
Esempio n. 2
0
        // Temporary method to initialize stuff with dummy values for easy testing
        public void FillWithData()
        {
            // Get judges and contestants from the database
            Database database = new Database();

            try
            {
                GlobalJudgeList      = database.FetchJudges();
                GlobalContestantList = database.FetchContestants();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }

            ContestJudgeList.Add(window.CurrentJudge);

            UpdateListViews();
        }