コード例 #1
0
 private void buttonDeleteTeacher_Click(object sender, EventArgs e)
 {
     try
     {
         if (teacherToDelete != null)
         {
             ITeacherLogic teacherOperations = Provider.GetInstance.GetTeacherOperations();
             teacherOperations.DeleteTeacher(teacherToDelete);
             this.CleanForm(true);
             this.labelSuccess.Text = Constants.SUCCESS_TEACHER_DELETED;
         }
         else
         {
             labelError.Text = Constants.ERROR_NOTEACHERFOUND;
         }
     }
     catch (CoreException ex)
     {
         this.labelError.Text = ex.Message;
     }
     catch (Exception)
     {
         this.labelError.Text = Constants.ERROR_UNEXPECTED;
     }
 }
コード例 #2
0
        private void comboBoxTeachersDocuments_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                this.labelSuccess.Text = string.Empty;
                if (IsDocumentSelected())
                {
                    CleanListBoxes();

                    string documentNumber = this.comboBoxTeachersDocuments.SelectedItem.ToString();

                    ITeacherLogic teacherOpertions = Provider.GetInstance.GetTeacherOperations();
                    Teacher       teacherToModify  = teacherOpertions.GetTeacherByDocumentNumber(documentNumber);
                    this.textBoxTeacherName.Text     = teacherToModify.GetName();
                    this.textBoxTeacherLastName.Text = teacherToModify.GetLastName();

                    this.PopulateListBoxes(teacherToModify);
                }
                else
                {
                    this.CleanForm();
                }
            }
            catch (CoreException ex)
            {
                CleanForm();
                this.labelError.Text = ex.Message;
            }
            catch (Exception)
            {
                CleanForm();
                this.labelError.Text = Constants.ERROR_UNEXPECTED;
            }
        }
コード例 #3
0
 private void OnTeacherDocument_ComboIndexChange(object sender, EventArgs e)
 {
     try
     {
         this.CleanForm();
         this.labelSuccess.Text = string.Empty;
         if (comboBoxTeachersDocuments.SelectedIndex >= 0)
         {
             buttonDeleteTeacher.Enabled = true;
             var           documentNumber    = comboBoxTeachersDocuments.SelectedItem as string;
             ITeacherLogic teacherOperations = Provider.GetInstance.GetTeacherOperations();
             this.teacherToDelete = teacherOperations.GetTeacherByDocumentNumber(documentNumber);
             this.FillFormWithTeacherData();
         }
         else
         {
             this.labelError.Text = Constants.ERROR_DOCUMENTNUMBER_REQUIRED;
         }
     }
     catch (CoreException ex)
     {
         this.teacherToDelete = null;
         this.labelError.Text = ex.Message;
     }
     catch (Exception)
     {
         this.teacherToDelete = null;
         this.labelError.Text = Constants.ERROR_UNEXPECTED;
     }
 }
コード例 #4
0
        private void buttonAddTeacher_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextboxesNotEmpty())
                {
                    var           newTeacher        = CreateTeacher();
                    ITeacherLogic teacherOperations = Provider.GetInstance.GetTeacherOperations();
                    teacherOperations.AddTeacher(newTeacher);

                    this.CleanForm();
                    this.labelSuccess.Text = Constants.SUCCESS_TEACHERREGISTRATION;;
                }
                else
                {
                    this.labelError.Text = Constants.ERROR_ALL_FIELDS_REQUIRED;
                }
            }
            catch (CoreException ex)
            {
                labelError.Text = ex.Message;
            }
            catch (Exception)
            {
                this.labelError.Text = Constants.ERROR_UNEXPECTED;
                //TODO: Try log the error somewhere.
            }
        }
コード例 #5
0
 private Provider()
 {
     this.teachersLogic   = new TeacherLogic(new TeacherPersistance());
     this.studentsLogic   = new StudentLogic(new StudentPersistance());
     this.subjectsLogic   = new SubjectLogic(new SubjectPersistance());
     this.vehiclesLogic   = new VehicleLogic(new VehiclePersistance());
     this.activitiesLogic = new ActivityLogic(new ActivityPersistance());
     this.paymentsLogic   = new PaymentLogic(new PaymentPersistence());
 }
コード例 #6
0
        public void AddTeacherToSystem()
        {
            ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();

            Teacher newTeacher = this.CreateRandomTeacher();

            teacherOperations.AddTeacher(newTeacher);

            Assert.IsNotNull(this.FindTeacherOnSystem(newTeacher.GetDocumentNumber()));
        }
コード例 #7
0
        private void PopulateSubjectsList(Teacher aTeacher)
        {
            this.listBoxTeacherSubjects.Items.Clear();
            ITeacherLogic teacherOperations = Provider.GetInstance.GetTeacherOperations();
            Teacher       selectedTeacher   = teacherOperations.GetTeacherByDocumentNumber(aTeacher.GetDocumentNumber());

            List <Subject> teacherSubjects = selectedTeacher.GetSubjects();

            this.LoadSubjectsIntoListBox(teacherSubjects);
        }
コード例 #8
0
        private void LoadTeacherListBox()
        {
            ITeacherLogic  teacherOperations = Provider.GetInstance.GetTeacherOperations();
            List <Teacher> systemTeachers    = teacherOperations.GetTeachers();

            foreach (Teacher teacher in systemTeachers)
            {
                this.listBoxSystemTeachers.Items.Add(teacher);
            }
        }
コード例 #9
0
        private void LoadDocumentNumberComboBox()
        {
            ITeacherLogic  teacherOpertions = Provider.GetInstance.GetTeacherOperations();
            List <Teacher> systemTeachers   = teacherOpertions.GetTeachers();

            foreach (Teacher teacher in systemTeachers)
            {
                this.comboBoxTeachersDocuments.Items.Add(teacher.GetDocumentNumber());
            }
        }
コード例 #10
0
        private void FillTeachersCombo()
        {
            ITeacherLogic teacherOperations = Provider.GetInstance.GetTeacherOperations();
            var           systemTeachers    = teacherOperations.GetTeachers();

            foreach (Teacher teacher in systemTeachers)
            {
                this.comboBoxTeachersDocuments.Items.Add(teacher.Document);
            }
        }
コード例 #11
0
        public void FindTeacherByDocumentNumber()
        {
            ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();

            string  documentNumber = "1234567-8";
            Teacher firstTeacher   = new Teacher(Utility.GetRandomName(), Utility.GetRandomLastName(), documentNumber);

            teacherOperations.AddTeacher(firstTeacher);

            Teacher teacherFound = teacherOperations.GetTeacherByDocumentNumber(documentNumber);

            Assert.IsNotNull(teacherFound);
        }
コード例 #12
0
        private void FillSystemTeachersListBox(int subjectCode)
        {
            ITeacherLogic  teacherOperations = Provider.GetInstance.GetTeacherOperations();
            ISubjectLogic  subjectOperations = Provider.GetInstance.GetSubjectOperations();
            List <Teacher> systemTeachers    = teacherOperations.GetTeachers();

            var subject = subjectOperations.GetSubjectByCode(subjectCode);
            var teachersOfThisSubject  = subject.Teachers;
            var teachersToAddToListBox = systemTeachers.Where(t => !teachersOfThisSubject.Any(st => st.Document == t.Document)).ToList();

            for (int index = 0; index < teachersToAddToListBox.Count(); index++)
            {
                this.listBoxSystemTeachers.Items.Add(teachersToAddToListBox[index]);
            }
        }
コード例 #13
0
        private bool IsThisSubjectAssignedToAnyTeacher(Subject subjectToDelete)
        {
            bool          isSubjectAssignedToATeacher = false;
            var           selectedSubject             = this.comboBoxSelectSubjectToDelete.SelectedItem as Subject;
            ITeacherLogic teacherOperations           = Provider.GetInstance.GetTeacherOperations();
            var           teachers = teacherOperations.GetTeachers(true);

            for (int index = 0; index < teachers?.Count(); index++)
            {
                var teacherSubjects = teachers[index].GetSubjects();
                if (teacherSubjects.Any(s => s.Code.Equals(subjectToDelete.Code)))
                {
                    isSubjectAssignedToATeacher = true;
                }
            }
            return(isSubjectAssignedToATeacher);
        }
コード例 #14
0
        public void AddSubjectToTeacher()
        {
            ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();
            ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();

            List <Subject> systemSubjects = SystemDummyData.GetInstance.GetSubjects();
            Subject        aSubject       = new Subject(123456, "Math");

            systemSubjects.Add(aSubject);

            Teacher newTeacher       = this.CreateRandomTeacher();
            Subject subjectToBeAdded = subjectOperations.GetSubjectByCode(123456);

            newTeacher.AddSubjectToTeach(subjectToBeAdded);

            Assert.IsTrue(newTeacher.GetSubjects().Count > 0);
        }
コード例 #15
0
 public void Load()
 {
     uow = new Mock <IUnitOfWork>();
     teacherRepository = new Mock <IGenericRepository <Teacher> >();
     uow.Setup(x => x.Teachers).Returns(teacherRepository.Object);
     uow.Setup(x => x.Teachers.FindById(It.IsAny <int>())).Returns(
         new Teacher
     {
         Id   = It.IsAny <int>(),
         Name = It.IsAny <string>(),
     });
     uow.Setup(x => x.Teachers.FindById(It.IsAny <int>())).Returns(
         new Teacher
     {
         Name = It.IsAny <string>()
     });
     teacherService = new TeacherLogic(uow.Object);
 }
コード例 #16
0
        public void ModifyTeacherLastName()
        {
            ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();

            Teacher newTeacher = new Teacher(Utility.GetRandomName(), "de Leon", "1234567-8");

            teacherOperations.AddTeacher(newTeacher);

            ModifyTeacherInput input = new ModifyTeacherInput();

            input.NewLastName    = "Diaz";
            input.DocumentNumber = "1234567-8";
            teacherOperations.ModifyTeacher(input);

            Teacher modifiedTeacher = teacherOperations.GetTeacherByDocumentNumber("1234567-8");

            Assert.AreEqual(modifiedTeacher.GetLastName(), input.NewLastName);
        }
コード例 #17
0
        public void DeleteTeacher()
        {
            try
            {
                ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();

                string  documentNumber = "1234567-8";
                Teacher teacher        = new Teacher(Utility.GetRandomName(), Utility.GetRandomLastName(), documentNumber);

                teacherOperations.AddTeacher(teacher);
                teacherOperations.DeleteTeacher(teacher);

                Assert.IsNull(this.FindTeacherOnSystem(teacher.GetDocumentNumber()));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
コード例 #18
0
        private void buttonModifyTeacher_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsDocumentSelected() && NameAndLastNameNotEmpty())
                {
                    string name     = textBoxTeacherName.Text;
                    string lastName = textBoxTeacherLastName.Text;
                    string document = comboBoxTeachersDocuments.SelectedItem.ToString();

                    var input = new ModifyTeacherInput
                    {
                        NewName        = name,
                        NewLastName    = lastName,
                        DocumentNumber = document,
                        NewSubjects    = GetSelectedSubjects()
                    };

                    ITeacherLogic teacherOpertions = Provider.GetInstance.GetTeacherOperations();
                    teacherOpertions.ModifyTeacher(input);

                    this.CleanForm();
                    this.labelSuccess.Text = Constants.SUCCESS_TEACHER_MODIFICATION;
                }
                else
                {
                    this.labelError.Text = Constants.ERROR_ALL_FIELDS_REQUIRED;
                }
            }
            catch (CoreException ex)
            {
                this.labelError.Text = ex.Message;
            }
            catch (Exception)
            {
                this.labelError.Text = Constants.ERROR_UNEXPECTED;
            }
        }
コード例 #19
0
        public void ModifyTeacherSubjects()
        {
            ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();

            #region Add subjects to the system
            List <Subject> systemSubjects = SystemDummyData.GetInstance.GetSubjects();
            Subject        subject1       = new Subject(1234, "Math");
            Subject        subject2       = new Subject(3216, "Physics");
            Subject        subject3       = new Subject(7418, "Chemistry");
            Subject        subject4       = new Subject(9632, "History");
            systemSubjects.Add(subject1);
            systemSubjects.Add(subject2);
            systemSubjects.Add(subject3);
            systemSubjects.Add(subject4);
            #endregion

            #region Add teacher to the system
            Teacher newTeacher = new Teacher(Utility.GetRandomName(), Utility.GetRandomLastName(), "1234567-8");
            newTeacher.AddSubjectToTeach(subject1);
            newTeacher.AddSubjectToTeach(subject2);
            newTeacher.AddSubjectToTeach(subject3);
            teacherOperations.AddTeacher(newTeacher);
            #endregion

            List <Subject> newSubjects = new List <Subject>();
            newSubjects.Add(subject1);
            newSubjects.Add(subject2);
            newSubjects.Add(subject4);

            ModifyTeacherInput input = new ModifyTeacherInput();
            input.NewSubjects    = newSubjects;
            input.DocumentNumber = "1234567-8";
            teacherOperations.ModifyTeacher(input);

            Teacher modifiedTeacher = teacherOperations.GetTeacherByDocumentNumber("1234567-8");

            Assert.IsTrue(Utility.CompareLists(modifiedTeacher.GetSubjects(), input.NewSubjects));
        }
コード例 #20
0
        public void DoNotAllowToAddDuplicateTeacherToSystem()
        {
            try
            {
                ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();

                Teacher firstTeacher  = this.CreateRandomTeacher();
                Teacher secondTeacher = new Teacher(firstTeacher.GetName(), firstTeacher.GetLastName(), firstTeacher.GetDocumentNumber());

                teacherOperations.AddTeacher(firstTeacher);
                teacherOperations.AddTeacher(secondTeacher);

                Assert.Fail();
            }
            catch (CoreException ex)
            {
                Assert.IsTrue(ex.Message.Equals("Teacher already exists."));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
コード例 #21
0
        public void RemoveSubjectFromTeacher()
        {
            ITeacherLogic teacherOperations = DummyProvider.GetInstance.GetTeacherOperations();
            ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();

            List <Subject> systemSubjects = SystemDummyData.GetInstance.GetSubjects();
            Subject        subject1       = new Subject(123456, "Math");
            Subject        subject2       = new Subject(654321, "Physics");

            systemSubjects.Add(subject1);
            systemSubjects.Add(subject2);

            Teacher newTeacher        = this.CreateRandomTeacher();
            Subject subjectToBeAdded1 = subjectOperations.GetSubjectByCode(123456);
            Subject subjectToBeAdded2 = subjectOperations.GetSubjectByCode(654321);

            newTeacher.AddSubjectToTeach(subjectToBeAdded1);
            newTeacher.AddSubjectToTeach(subjectToBeAdded2);

            newTeacher.RemoveSubject(subjectToBeAdded1);
            List <Subject> teacherSubjects = newTeacher.GetSubjects();

            Assert.IsFalse(teacherSubjects.Exists(item => item.Equals(subjectToBeAdded1)));
        }
コード例 #22
0
 public GetListTeachersController(ITeacherLogic teacherLogic)
 {
     _teacherLogic = teacherLogic;
 }
コード例 #23
0
 public AddTeacherToSchoolController(ITeacherLogic teacherLogic)
 {
     _teacherLogic = teacherLogic;
 }
コード例 #24
0
 public StudentsOfTeacherController(ITeacherLogic teacherLogic)
 {
     _teacherLogic = teacherLogic;
 }
コード例 #25
0
 public AddTeacherController(ITeacherLogic teacherLogic)
 {
     _teacherLogic = teacherLogic;
 }