예제 #1
0
        /*
         * Adds an option
         */
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxCandidate.SelectedItem != null && comboBoxDepartment.SelectedItem != null)
                {
                    Candidate  selectedCandidateCombo  = (Candidate)comboBoxCandidate.SelectedItem;
                    string     idCandidate             = selectedCandidateCombo.Id.ToString();
                    Department selectedDepartmentCombo = (Department)comboBoxDepartment.SelectedItem;
                    string     idDepartment            = selectedDepartmentCombo.Id.ToString();
                    optionController.add(idCandidate, idDepartment);

                    setSelectedDepartment(selectedDepartmentCombo);
                    refreshSelectedDepartment();
                    refreshSelectedCandidate();
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("You must select a candidate and a department.");
                }
            } catch (RepositoryException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            } catch (ValidatorException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
        }
예제 #2
0
        public void addTest()
        {
            repoCandidate.add(new Candidate(1, "ca", "0742333444", "adr"));
            repoDepartment.add(new Department(2, "de", 123));

            controller.add("1", "2");
            Pair <int, int> p  = new Pair <int, int>(1, 2);
            Option          op = controller.getById("1 2");

            Assert.AreEqual(op.Id, p);
        }