示例#1
0
        public Course_Ent GetCourse_Ent(int id)
        {
            Course      course      = db.Courses.Where(c => c.CourseID == id).FirstOrDefault();
            Course_Ent  course_Ent  = new Course_Ent();
            Teacher_DAL teacher_DAL = new Teacher_DAL();
            Teacher_Ent teacher_Ent = new Teacher_Ent();

            course_Ent.CourseID     = course.CourseID;
            course_Ent.CourseName   = course.CourseName;
            course_Ent.Location     = course.Location;
            teacher_Ent.TeacherID   = course.TeacherID;
            teacher_Ent.TeacherName = teacher_DAL.GetName(course.TeacherID);
            course_Ent.Teacher      = teacher_Ent;

            return(course_Ent);
        }
示例#2
0
        public List <Course_Ent> GetCourses()
        {
            Teacher_DAL       teacher_DAL = new Teacher_DAL();
            List <Course_Ent> courses     = new List <Course_Ent>();

            foreach (Course course in db.Courses.ToList())
            {
                Course_Ent course_ent = new Course_Ent();

                course_ent.CourseID   = course.CourseID;
                course_ent.CourseName = course.CourseName;
                course_ent.Location   = course.Location;

                Teacher_Ent teacher_Ent = new Teacher_Ent();
                teacher_Ent.TeacherID   = course.TeacherID;
                teacher_Ent.TeacherName = teacher_DAL.GetName(course.TeacherID);

                course_ent.Teacher = teacher_Ent;

                courses.Add(course_ent);
            }

            return(courses);
        }