Esempio n. 1
0
        public Schedule GetScheduleById(int scheduleId, ref List<string> errors)
        {
            Schedule pocoSchedule = new Schedule();
            course_schedule db_Schedule;

            try
            {
                db_Schedule = this.context.course_schedule.Find(scheduleId);

                var day = new schedule_day();
                var time = new schedule_time();
                var instructor = new instructor();
                day = this.context.schedule_day.Find((int)db_Schedule.schedule_day_id);
                time = this.context.schedule_time.Find((int)db_Schedule.schedule_time_id);
                instructor = this.context.instructors.Find((int)db_Schedule.instructor_id);

                pocoSchedule.ScheduleId = db_Schedule.schedule_id;
                pocoSchedule.Year = db_Schedule.year.ToString();
                pocoSchedule.Quarter = db_Schedule.quarter;
                pocoSchedule.Session = db_Schedule.session;
                pocoSchedule.Instructor = new Instructor
                {
                    InstructorId = instructor.instructor_id,
                    FirstName = instructor.first_name,
                    LastName = instructor.last_name,
                };
                pocoSchedule.Day = new ScheduleDay
                {
                    DayId = day.schedule_day_id,
                    Day = day.schedule_day1
                };
                pocoSchedule.Time = new ScheduleTime
                {
                    TimeId = time.schedule_time_id,
                    Time = time.schedule_time1
                };
                pocoSchedule.Course = new Course
                {
                    CourseId = db_Schedule.course.course_id,
                    Title = db_Schedule.course.course_title,
                    Description = db_Schedule.course.course_description,
                    Level = db_Schedule.course.course_level,
                };
            }
            catch (Exception e)
            {
                errors.Add("Error occured in ScheduleRepository.GetScheduleList: " + e);
            }

            return pocoSchedule;
        }
Esempio n. 2
0
        public List<Schedule> GetScheduleList(string year, string quarter, ref List<string> errors)
        {
            var scheduleList = new List<Schedule>();
            List<Schedule> pocoScheduleList = new List<Schedule>();
            IEnumerable<course_schedule> db_ScheduleList;

            try
            {
                var myYear = int.Parse(year);
                db_ScheduleList = this.context.course_schedule.Include("schedule_day").Include("schedule_time").Include("instructor").Where(x => x.quarter == quarter && x.year == myYear);

                foreach (course_schedule c in db_ScheduleList)
                {
                    var day = new schedule_day();
                    var time = new schedule_time();
                    var instructor = new instructor();

                    var schedule = new Schedule
                    {
                        ScheduleId = c.schedule_id,
                        Year = c.year.ToString(),
                        Quarter = c.quarter,
                        Session = c.session,
                        Instructor = new Instructor
                        {
                            InstructorId = c.instructor.instructor_id,
                            FirstName = c.instructor.first_name,
                            LastName = c.instructor.last_name,
                        },
                        Day = new ScheduleDay
                        {
                            DayId = c.schedule_day.schedule_day_id,
                            Day = c.schedule_day.schedule_day1
                        },
                        Time = new ScheduleTime
                        {
                            TimeId = c.schedule_time.schedule_time_id,
                            Time = c.schedule_time.schedule_time1
                        },
                        Course = new Course
                        {
                            CourseId = c.course.course_id,
                            Title = c.course.course_title,
                            Description = c.course.course_description
                        }
                    };

                    scheduleList.Add(schedule);
                }
            }
            catch (Exception e)
            {
                errors.Add("Error occured in ScheduleRepository.GetScheduleList: " + e);
            }

            return scheduleList;
        }
Esempio n. 3
0
        public List<Schedule> GetInstructorSchedule(int instructorId, ref List<string> errors)
        {
            IEnumerable<course_schedule> db_List;
            List<Schedule> pocoList = new List<Schedule>();

            try
            {
                db_List = this.context.course_schedule.Include("schedule_day").Include("schedule_time").Include("instructor").Where(x => x.instructor_id == instructorId);

                foreach (course_schedule c in db_List)
                {
                    var day = new schedule_day();
                    var time = new schedule_time();
                    var instructor = new instructor();

                    var schedule = new Schedule
                    {
                        ScheduleId = c.schedule_id,
                        Year = c.year.ToString(),
                        Quarter = c.quarter,
                        Session = c.session,
                        Instructor = new Instructor
                        {
                            InstructorId = c.instructor.instructor_id,
                            FirstName = c.instructor.first_name,
                            LastName = c.instructor.last_name,
                        },
                        Day = new ScheduleDay
                        {
                            DayId = c.schedule_day.schedule_day_id,
                            Day = c.schedule_day.schedule_day1
                        },
                        Time = new ScheduleTime
                        {
                            TimeId = c.schedule_time.schedule_time_id,
                            Time = c.schedule_time.schedule_time1
                        },
                        Course = new Course
                        {
                            CourseId = c.course.course_id,
                            Title = c.course.course_title,
                            Description = c.course.course_description,
                            Level = c.course.course_level,
                        }
                    };

                    pocoList.Add(schedule);
                }
            }
            catch (Exception e)
            {
                errors.Add("Error occured in ScheduleRepository.GetDays: " + e);
            }

            return pocoList;
        }