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();
        }
Esempio n. 3
0
        /// <summary>
        /// Remove a added judge from the contest
        /// </summary>
        public void RemoveJudgeFromContest()
        {
            try
            {
                // Collect the chosen judge, gets the full name of the judge
                var judgeName = View.ListViewLocalJudges.SelectedItems[0].SubItems[0].Text + " " + View.ListViewLocalJudges.SelectedItems[0].SubItems[1].Text;

                Judge judgeToBeRemoved = null;

                // if you are the judge creating the contest, you cannot be removed.
                if (judgeName != window.CurrentJudge.GetFullName())
                {
                    // find the right Judge object
                    foreach (var j in ContestJudgeList)
                    {
                        if (String.Equals(j.GetFullName(), judgeName))
                        {
                            judgeToBeRemoved = j;
                        }
                    }

                    // remove from contestlist
                    ContestJudgeList.Remove(judgeToBeRemoved);

                    UpdateListViews();
                }
                else
                {
                    MessageBox.Show("Du kan inte ta bort dig själv!");
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Välj en domare!");
            }
        }