Example #1
0
        public JsonResult GetClassScheduleByDepartmentId(int departmentId)
        {
            List <Course>           courses   = courseManager.GetCoursesById(departmentId);
            List <ScheduleViewMode> schedules = new List <ScheduleViewMode>();

            foreach (var course in courses)
            {
                string scheduleView = allocateClassroomsManager.GetAllSchedule(departmentId);
                if (scheduleView == "")
                {
                    scheduleView = "Not Scheduled Yet";
                }
                ScheduleViewMode scheduleViewMode = new ScheduleViewMode();
                scheduleViewMode.CourseCode = course.Code;
                scheduleViewMode.CourseName = course.Name;
                scheduleViewMode.Schedule   = scheduleView;
                schedules.Add(scheduleViewMode);
            }
            return(Json(schedules));
        }
        //-------------------Class Schedule------------------
        public List <ScheduleViewMode> GetAllSchedule(int departmentId)
        {
            string query = "SELECT * FROM AllocateClassroomsView WHERE DepartmentId=" + departmentId + "";

            Command = new SqlCommand(query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            List <ScheduleViewMode> scheduleList = new List <ScheduleViewMode>();

            while (Reader.Read())
            {
                ScheduleViewMode schedule = new ScheduleViewMode();
                schedule.CourseCode = Reader["Code"].ToString();
                schedule.CourseName = Reader["Name"].ToString();
                schedule.RoomName   = Reader["RoomCode"].ToString();
                schedule.DayName    = Reader["Day"].ToString();
                schedule.FromTime   = Convert.ToDateTime(Reader["FromTime"].ToString());
                schedule.ToTime     = Convert.ToDateTime(Reader["ToTime"].ToString());
                scheduleList.Add(schedule);
            }
            Reader.Close();
            Connection.Close();
            return(scheduleList);
        }