Esempio n. 1
0
        public void LoadFields(Object anObject, TextBox textNameStudent, TextBox textLastNameStudent, TextBox textStudentNumber, NumericUpDown numericCi, NumericUpDown numericX, NumericUpDown numericY, ListBox list, ListBox listOtherSubject)
        {
            Student student = anObject as Student;

            textNameStudent.Text     = student.Name;
            textLastNameStudent.Text = student.LastName;
            textStudentNumber.Text   = student.StudentNumber + "";
            numericCi.Value          = student.Ci;
            numericX.Value           = student.Coordinates.X;
            numericY.Value           = student.Coordinates.Y;
            SubjectLogic   logic       = new SubjectLogic();
            List <Subject> allSubjects = logic.GetAllSubjects();

            foreach (Subject item in allSubjects)
            {
                if (student.Subjects.Contains(item))
                {
                    list.Items.Add(allSubjects.Find(x => x.Code == item.Code));
                }
                else
                {
                    listOtherSubject.Items.Add(item);
                }
            }
        }
Esempio n. 2
0
        public List <Subject> GetAllSubjects()
        {
            List <Subject> sList = new List <Subject>();

            sList = ToSubjectList(slogic.GetAllSubjects());
            return(sList);
        }
Esempio n. 3
0
        public void ModifySubjectName()
        {
            ClearRepository();
            Subject      newSubject    = testSubject();
            Subject      editedSubject = testSubject();
            SubjectLogic testLogic     = new SubjectLogic();
            string       testName      = "5";

            editedSubject.Name = testName;
            testLogic.Add(newSubject);
            testLogic.Modify(newSubject, editedSubject);

            Assert.IsFalse(testLogic.GetAllSubjects().ElementAt(0).Name == newSubject.Name);
        }
Esempio n. 4
0
        public void LoadSubjectsByStudents(Object anObject, ListBox listSubjects)
        {
            Student        student     = anObject as Student;
            SubjectLogic   logic       = new SubjectLogic();
            List <Subject> allSubjects = logic.GetAllSubjects();

            foreach (Subject item in student.Subjects)
            {
                if (allSubjects.Contains(item))
                {
                    listSubjects.Items.Add(allSubjects.Find(x => x.Code == item.Code));
                }
            }
        }
Esempio n. 5
0
        public void LoadSubjectsByTeacher(Object anObject, ListBox listSubjects)
        {
            Teacher        teacher     = anObject as Teacher;
            SubjectLogic   logic       = new SubjectLogic();
            List <Subject> allSubjects = logic.GetAllSubjects();

            foreach (Subject item in allSubjects)
            {
                if (teacher.Subjects.Contains(item))
                {
                    listSubjects.Items.Add(allSubjects.Find(x => x.Code == item.Code));
                }
            }
        }
Esempio n. 6
0
        public void LoadAllSubjects(ListBox list)
        {
            SubjectLogic   logic      = new SubjectLogic();
            List <Subject> allObjects = new List <Subject>();

            allObjects = logic.GetAllSubjects();
            if (allObjects.Count == 0)
            {
                throw new NoSubjectInSystemException("No hay Materias ingresadas en el sistema");
            }
            foreach (Subject item in allObjects)
            {
                list.Items.Add(item);
            }
        }
Esempio n. 7
0
        public void GenerateNewCodeSuccess()
        {
            ClearRepository();
            string       testCode = "testCode";
            SubjectLogic logic    = new SubjectLogic();

            logic.AddNewSubject("testName");
            List <Subject> allSubjects = logic.GetAllSubjects();
            bool           assertion   = true;

            if (!logic.IsEmpty())
            {
                Subject subjectTest = allSubjects.ElementAt(0);
                assertion = subjectTest.Code.Equals(testCode);
            }
            Assert.IsFalse(assertion);
        }
Esempio n. 8
0
        public void CanIModifySubject()
        {
            ClearRepository();
            Subject oldSubject = testSubject();
            Subject newSubject = testSubject();

            newSubject.Name = "aa";
            SubjectLogic logic = new SubjectLogic();

            logic.Add(oldSubject);
            logic.Modify(oldSubject, newSubject);
            List <Subject> allSubjects = logic.GetAllSubjects();
            bool           assertion   = false;

            if (!logic.IsEmpty())
            {
                Subject subjectTest = allSubjects.ElementAt(0);
                assertion = subjectTest.Name.Equals("aa");
            }
            Assert.IsTrue(assertion);
        }
Esempio n. 9
0
        public void LoadFields(Object anObject, TextBox textName, TextBox textCode, TextBox textLastName, ListBox list, ListBox listOtherSubject)
        {
            Teacher teacher = anObject as Teacher;

            textName.Text     = teacher.Name;
            textLastName.Text = teacher.LastName;
            textCode.Text     = teacher.Id + "";
            SubjectLogic   logic       = new SubjectLogic();
            List <Subject> allSubjects = logic.GetAllSubjects();

            foreach (Subject item in allSubjects)
            {
                if (teacher.Subjects.Contains(item))
                {
                    list.Items.Add(allSubjects.Find(x => x.Code == item.Code));
                }
                else
                {
                    listOtherSubject.Items.Add(item);
                }
            }
        }