public ActionResponse Allocate(RoomAllocation aRoomAllocation) { ActionResponse response = new ActionResponse(); try { int compare = DateTime.Compare(aRoomAllocation.StartTime, aRoomAllocation.EndTime); if (compare > 0) { response.Class = "danger"; response.Message = "End Time [" + aRoomAllocation.EndTime.ToString("hh:mm tt") + "] must be grater than Start Time [" + aRoomAllocation.StartTime.ToString("hh:mm tt") + "]."; return response; } bool isOverlap = aClassroomGateway.IsOverlap(aRoomAllocation); if (isOverlap) { response.Class = "danger"; response.Message = "Overlapping problem: Another class is allocated with this schedule."; return response; } aClassroomGateway.Allocate(aRoomAllocation); response.Class = "success"; response.Message = "Room Allocated successfully."; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }
public ActionResponse Save(Department aDepartment) { ActionResponse response = new ActionResponse(); try { bool isDepartmentCodeExists = aDepartmentGateway.IsDepartmentCodeExists(aDepartment.DepartmentCode); if (isDepartmentCodeExists) { response.Class = "warning"; response.Message = "Department Code [" + aDepartment.DepartmentCode + "] is already exists."; return response; } bool isDepartmentNameExists = aDepartmentGateway.IsDepartmentNameExists(aDepartment.DepartmentName); if (isDepartmentNameExists) { response.Class = "warning"; response.Message = "Department Name [" + aDepartment.DepartmentName + "] is already exists."; return response; } aDepartmentGateway.Save(aDepartment); response.Class = "success"; response.Message = "Department Saved Successfully"; } catch (SqlException ex) { response.Class = "danger"; response.Message = ex.Message; } return response; }
public ActionResponse Save(Course aCourse) { ActionResponse response = new ActionResponse(); try { bool isCourseCodeExists = aCourseGateway.IsCourseCodeExists(aCourse.CourseCode); if (isCourseCodeExists) { response.Class = "danger"; response.Message = "Course Code [" + aCourse.CourseCode + "] is already exists."; return response; } bool isCourseNameExists = aCourseGateway.IsCourseNameExists(aCourse.CourseName); if (isCourseNameExists) { response.Class = "danger"; response.Message = "Course Name [" + aCourse.CourseName + "] is already exists."; return response; } aCourseGateway.Save(aCourse); response.Class = "success"; response.Message = "Course Saved Successfully"; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }
public ActionResponse Save(Student aStudent) { ActionResponse response = new ActionResponse(); try { bool isEmailExists = aStudentGateway.IsEmailExists(aStudent.StudentEmail); if (isEmailExists) { response.Class = "danger"; response.Message = "Email [" + aStudent.StudentEmail + "] is already exists."; return response; } //EEE-2016-001 string deptCode = aDepartmentGateway.GetDepartmentCodeById(aStudent.DepartmentId); //int stdId = aStudentGateway.GetMaxStudentId(); //string regNo = deptCode + "-" + aStudent.RegDate.Year + "-" + stdId.ToString("D3"); int nextId = aStudentGateway.GetRegSl(aStudent.DepartmentId, aStudent.RegDate.Year); string regNo = deptCode + "-" + aStudent.RegDate.Year + "-" + nextId.ToString("D3"); aStudent.RegNo = regNo; aStudentGateway.Save(aStudent); response.Class = "success"; response.Message = regNo; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }
public ActionResponse UnallocateClassrooms() { ActionResponse response = new ActionResponse(); try { aResetGateway.Reset("RoomAllocation"); response.Class = "success"; response.Message = "Room allocation information has been reseted successfully."; } catch (SqlException ex) { response.Class = "danger"; response.Message = ex.Message; } return response; }
public ActionResponse UnassignCourses() { ActionResponse response = new ActionResponse(); try { aResetGateway.Reset("CourseAssign"); aResetGateway.Reset("Enrollments"); aResetGateway.Reset("StudentResults"); response.Class = "success"; response.Message = "All Courses has been UnassignED successfully."; } catch (SqlException ex) { response.Class = "danger"; response.Message = ex.Message; } return response; }
public ActionResponse Save(StudentResult aStudentResult) { ActionResponse response = new ActionResponse(); try { bool isAlreadySaved = aResultGateway.IsAlreadySaved(aStudentResult); if (isAlreadySaved) { response.Class = "danger"; response.Message = "This result is already saved."; return response; } aResultGateway.Save(aStudentResult); response.Class = "success"; response.Message = "Reasult Saved Successfully."; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }
public ActionResponse AssignCourse(CourseAssign courseAssign) { ActionResponse response = new ActionResponse(); try { bool isAlreadyAssigned = aTeacherGateway.IsAlreadyAssigned(courseAssign); if (isAlreadyAssigned) { response.Class = "danger"; response.Message = "This course is already assigned to another teacher."; return response; } aTeacherGateway.AssignCourse(courseAssign); response.Class = "success"; response.Message = "Course Assigned successfully."; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }
public ActionResponse Save(Teacher aTeacher) { ActionResponse response = new ActionResponse(); try { bool isEmailExists = aTeacherGateway.IsEmailExists(aTeacher.TeacherEmail); if (isEmailExists) { response.Class = "danger"; response.Message = "Email [" + aTeacher.TeacherEmail + "] is already exists."; return response; } aTeacherGateway.Save(aTeacher); response.Class = "success"; response.Message = "Teacher Saved Successfully"; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }
public ActionResponse Enroll(Enrollment aEnrollment) { ActionResponse response = new ActionResponse(); try { bool isAlreadyEnrolled = aStudentGateway.IsAlreadyEnrolled(aEnrollment); if (isAlreadyEnrolled) { response.Class = "danger"; response.Message = "This student is already enrolled in this course."; return response; } aStudentGateway.Enroll(aEnrollment); response.Class = "success"; response.Message = "Enrollment successfully completed."; } catch (SqlException ex) { response.Class = "warning"; response.Message = ex.Message; } return response; }