public string SaveTeacher(Teacher aTeacher)
 {
     aTeacherGateway = new TeacherGateway();
     if (!DoesThisEmailExist(aTeacher))
         return aTeacherGateway.SaveTeacher(aTeacher);
     else
         return "This Email Already Exist";
 }
 public string SaveTeacerCourse(TeacherCourse aTeacherCourse, float credit)
 {
     aTeacherGateway = new TeacherGateway();
     if (!CheckTeacherTime(aTeacherCourse))
        if (!DoesThisCourseExist(aTeacherCourse))
      return aTeacherGateway.SaveTeacerCourse(aTeacherCourse, credit);
         else
            return "This Course Already Assigned";
     else
         return "This Time Teacher Handel Another Course";
 }
        public string GetTeacherId(int departmentId)
        {
            string teacherId = "";
            aTeacherGateway = new TeacherGateway();
            int id = aTeacherGateway.GetTeacherId(departmentId);
            if (id < 10)
                teacherId = "0" + id;
            else

                teacherId = id.ToString();

            return teacherId;
        }
 public string ResetCourseScheduleAndUnassignedAllCourse()
 {
     try
     {
         ResetAssignedCourses();
         ResetCourseSchedule();
         ResetUnassignedTeacherCourses();
         TeacherGateway aTeacherGateway = new TeacherGateway();
         aTeacherGateway.UpdateTeacherCredit();
         DeleteTeacherSchedule();
         return("Unassigned & Unschedule All courses");
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
 private bool CheckTeacherTime(TeacherCourse aTeacherCourse)
 {
     aTeacherGateway = new TeacherGateway();
     ScheduleGateway aScheduleGateway = new ScheduleGateway();
     List<int> coursesId = new List<int>();
     coursesId = aTeacherGateway.GetTeacherAssignCoursesId(aTeacherCourse);
     List<Schedule> schedules = new List<Schedule>();
     schedules = aScheduleGateway.GetTeacherAllSchedules(coursesId);
     List<Schedule> currentScheduleList = new List<Schedule>();
     currentScheduleList = aScheduleGateway.GetCurrentCourseSchedules(aTeacherCourse);
     foreach (Schedule schedule in currentScheduleList)
     {
         foreach (Schedule aSchedule in schedules)
         {
             if (schedule.DayId == aSchedule.DayId && ((schedule.StartTime <= aSchedule.StartTime && schedule.EndingTime >= aSchedule.StartTime) || (schedule.StartTime <= aSchedule.EndingTime & schedule.EndingTime >= aSchedule.EndingTime)))
             {
                 return true;
             }
         }
     }
     return false;
 }
 public Teacher GetTeacherCreditInfo(Teacher aTeacher)
 {
     aTeacherGateway = new TeacherGateway();
     return aTeacherGateway.GetTeacherCreditInfo(aTeacher);
 }
 public Teacher GetTeacher(Teacher aTeacher)
 {
     aTeacherGateway = new TeacherGateway();
     return aTeacherGateway.GetTeacher(aTeacher);
 }
 public List<Teacher> GetAllTeachers(int departmentId)
 {
     aTeacherGateway = new TeacherGateway();
     return aTeacherGateway.GetAllTeachers(departmentId);
 }
 private bool DoesThisEmailExist(Teacher aTeacher)
 {
     List<string> emails = new List<string>();
     aTeacherGateway = new TeacherGateway();
     emails = aTeacherGateway.GetAllEmails();
     foreach (string email in emails)
     {
         if (email == aTeacher.Email)
         {
             return true;
         }
     }
     return false;
 }
        public string ResetCourseScheduleAndUnassignedAllCourse()
        {
            try
            {
                ResetAssignedCourses();
                ResetCourseSchedule();
                ResetUnassignedTeacherCourses();
                TeacherGateway aTeacherGateway = new TeacherGateway();
                aTeacherGateway.UpdateTeacherCredit();
                DeleteTeacherSchedule();
                return "Unassigned & Unschedule All courses";
            }
            catch (Exception exception)
            {

                throw exception;
            }
        }