/// <summary>
 ///     Add a Department to the Instutite
 /// </summary>
 /// <param name="dept">The Department to add</param>
 public void addDepartment(Department dept)
 {
     if (deptList == null)
     {
         deptList = new LinkedList();
     }
     deptList.addAtTail(dept);
 }
Exemplo n.º 2
0
        public void Process_NewDepartmentEvent_SetsNAmeAndId()
        {
            var id = Guid.NewGuid();
            var @event = new NewDepartmentEvent(id, "Test Department");
            var department = new Department();
            department.Process(@event);

            Assert.Equal(id, department.Id);
            Assert.Equal("Test Department", department.Name);
        }
 public Department GetById(Guid id)
 {
     var stream = _eventStore.Load(id);
     var department = new Department();
     foreach (var ev in stream)
     {
         department.Process(ev);
     }
     return department;
 }
Exemplo n.º 4
0
        private Department GetTestDepartment()
        {
            var id = Guid.Parse(departmentId);
            var department = new Department()
            {
                Id = id,
                Name = "Test Department"
            };

            return department;
        }
Exemplo n.º 5
0
        public void Process_NewCommitteeEvent_SetsCommitteeProperties()
        {
            var id = Guid.NewGuid();
            var @event = new NewCommitteeEvent(id, "Test Committee", "mandate");
            var department = new Department();
            department.Process(@event);

            var committee = department.Committees.First();
            Assert.Equal(id, committee.Id);
            Assert.Equal("Test Committee", committee.Name);
        }
        public void ShouldGetAllStudents()
        {
            var departmentFromDb = new Department { Id = 2, Code = "Code" };
            var studentsFromDb = new List<Student> { new Student { Id = 1, Department = departmentFromDb } };
            this.mockStudentRepository.Setup(repository => repository.GetAll()).Returns(studentsFromDb);

            var students = studentService.GetAll();

            Assert.That(students, Is.Not.Null);
            Assert.That(students.Count, Is.EqualTo(1));
            //TODO:to be fixed
            //Assert.That(students.Select(x => x.Id), Is.EqualTo(studentsFromDb.Select(x => x.Id)));
            //Assert.That(students[0].Department.Id, Is.EqualTo(departmentFromDb.Id));
        }
 public Department Build()
 {
     var department = new Department { Code = this.Code, Name = this.Name, };
     return department;
 }
Exemplo n.º 8
0
 public IActionResult Create()
 {
     var department = new Department();
     var vm = Mapper.Map<DepartmentViewModel>(department);
     return View(vm);
 }
Exemplo n.º 9
0
        /// <summary>
         /// load all the depts from the database
         /// </summary>
        private void loadDepartmentList()
        {
            Department tempDept ;
            string sqlStatment = "SELECT * FROM Department";
            try 
	        {	        
		        OpenConection();
                cmd = new OleDbCommand(sqlStatment, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["Deleted"].ToString().Equals("False"))
                    {
                        tempDept = new Department(
                            reader["ID"].ToString(),
                            reader["Dept_Name"].ToString());
                        deptList.addAtTail(tempDept);
                    }
                }
                CloseConnection();
	        }
	        catch (Exception e)
	        {
                MessageBox.Show(e.ToString());
	        }
        }
Exemplo n.º 10
0
 /// <summary>
 ///     Insert a department into the database
 /// </summary>
 /// <param name="dept">The Department to be inserted</param>
 public void insertDept(Department dept)
 {
     string sql = "INSERT INTO Department VALUES('"+ dept.name + "')";
     excuteNonQuery(sql);
 }
Exemplo n.º 11
0
 /// <summary>
 ///     Update a Department
 /// </summary>
 /// <param name="dept">The updated Department</param>
 public void updateDept(Department dept)
 {
     string sql;
     sql = "Update Department Dept_Name=";
     sql += "'" + dept.name + "'";
     excuteNonQuery(sql);
 }
Exemplo n.º 12
0
 /// <summary>
 ///     Update a Department
 /// </summary>
 /// <param name="dept">The updated Department</param>
 private void updateDept(Department dept)
 {
     string sql;
     sql = "Update Department Dept_Name=";
     sql += "'" + dept.getName() + "'";
     excuteNonQuery(sql);
 }
Exemplo n.º 13
0
 /// <summary>
 ///     Insert a department into the database
 /// </summary>
 /// <param name="dept">The Department to be inserted</param>
 private void insertDept(Department dept)
 {
     string sql = "INSERT INTO Department VALUES('"+ dept.getName() + "')";
     excuteNonQuery(sql);
 }
Exemplo n.º 14
0
        /// <summary>
        ///  Load all the Lecturers for a given Department
        /// </summary>
        /// <param name="dept">The Department the Lecturers are in</param>
        /// <returns>LinkedList of Lecturer</returns>
        public LinkedList loadLectuerList(Department dept)
        {
            LinkedList lectureList = new LinkedList();
            Lecturer newLec;
            string sqlStatment = "SELECT Lec_Name, Initials, Email, MaxHours, MaxConsecHours, MinSlotsPerDays, SlotsOff, Deleted";
            sqlStatment += "FROM Lecturer WHERE Lecturer.Dept_ID LIKE" + dept.getID();
                try
                {
                    OpenConection();
                    cmd = new OleDbCommand(sqlStatment, conn);
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        if (reader["Deleted"].ToString().Equals("False"))
                        {
                            newLec = new Lecturer();
                            newLec.setId(reader["ID"].ToString());
                            newLec.setName(reader["Lec_Name"].ToString());
                            newLec.setInitials(reader["Initials"].ToString());
                            newLec.setEmail(reader["Email"].ToString());
                            newLec.setMaxHours(Convert.ToInt32(reader["MaxHours"]));
                            newLec.setMaxConsecHours(Convert.ToInt32(reader["MaxConsecHours"]));
                            newLec.setMinSlotsPerDay(Convert.ToInt32(reader["MinSlotsPerDays"]));
                            newLec.setSlotsOff(reader["SlotsOff"].ToString());
                            lectureList.addAtTail(newLec);

                        }
                    }
                    CloseConnection();
                }
                catch
                {
                    // MessageBox.Show("Failed to get data from source");
                }
            return lectureList;
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Returns a list of Departments
        /// </summary>
        /// <param name="institute">The Institute the Departments are in</param>
        /// <returns>A LinkedList of Departments</returns>
        public LinkedList loadDepartmentList(Institute institute)
        {
            LinkedList deptList = new LinkedList();
            Department tempDept ;
            string sqlStatment = "SELECT * FROM Department";
            try
            {
                OpenConection();
                cmd = new OleDbCommand(sqlStatment, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["Deleted"].ToString().Equals("False"))
                    {
                        tempDept = new Department();
                        tempDept.setId(reader["ID"].ToString());
                        tempDept.setName(reader["Dept_Name"].ToString());
                        tempDept.setLecturerList(loadLectuerList(tempDept));
                        tempDept.setCourseList(loadCourseList(tempDept));
                        deptList.addAtTail("tempDept");
                    }

                }
                CloseConnection();
            }
            catch
            {

            }
            return deptList;
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Load LinkedList of Course for a Department
        /// </summary>
        /// <param name="dept">The Department the Courses are in</param>
        /// <returns>A LinkedList of Course</returns>
        public LinkedList loadCourseList(Department dept)
        {
            LinkedList courses = new LinkedList();
            Course tempCourse ;

            string sqlStatment = "SELECT ID, Code, CourseName, NumOfStudents FROM Course WHERE DeptId Like  " +  dept.getID();
            try
            {
                OpenConection();
                cmd = new OleDbCommand(sqlStatment, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["Deleted"].ToString().Equals("False"))
                    {
                        tempCourse = new Course();
                        tempCourse.setID(reader["ID"].ToString());
                        tempCourse.setCourseCode(reader["Code"].ToString());
                        tempCourse.setName(reader["CourseName"].ToString());
                        tempCourse.setNumOfStudents(Convert.ToInt32(reader["NumOfStudents"]));
                        tempCourse.setModuleList(LoadModuleList(tempCourse));
                        courses.addAtTail(tempCourse);
                    }

                }
                CloseConnection();
            }
            catch
            {
                // MessageBox.Show("Failed to get data from source");
            }

            return courses ;
        }