public List <Course> GetCourseByName(string name) { try { CourseRepo courseRepo = new CourseRepo(); List <Course> courses = courseRepo.GetCourses(); var result = courses.Where(item => item.Name == name).ToList(); if (result.Any()) { return(result); } else { throw new PrometheusException("No Course Found!"); } } catch (Exception) { throw; } }
public List <TeacherCourses> GetCoursesByTeacherID(int id) { try { TeachesRepo teachesRepo = new TeachesRepo(); List <Teaches> teachesList = teachesRepo.GetAllTeaches(); CourseRepo courseRepo = new CourseRepo(); List <Course> courses = courseRepo.GetCourses(); var result = teachesList.Where(item => item.TeacherID == id).Join( courses, teaches => teaches.CourseID, course => course.CourseID, (teaches, course) => new TeacherCourses { TeacherID = id, CourseID = teaches.CourseID, Name = course.Name, StartDate = course.StartDate, EndDate = course.EndDate } ).ToList(); if (result.Any()) { return(result); } else { throw new PrometheusException("No Enrollments Found!"); } } catch (Exception) { throw; } }
//Get List of Courses in which student is Enrolled public List <EnrolledCourse> GetCoursesByStudentID(int id) { try { EnrollmentRepo enrollmentRepo = new EnrollmentRepo(); List <Enrollment> enrollments = enrollmentRepo.GetEnrollments(); CourseRepo courseRepo = new CourseRepo(); List <Course> courses = courseRepo.GetCourses(); var result = enrollments.Where(item => item.StudentID == id).Join( courses, enrollment => enrollment.CourseID, course => course.CourseID, (enrollment, course) => new EnrolledCourse { EnrollmentID = enrollment.EnrollmentID, CourseID = enrollment.CourseID, Name = course.Name, StartDate = course.StartDate, EndDate = course.EndDate } ).ToList(); if (result.Any()) { return(result); } else { throw new PrometheusException("No Enrollments Found!"); } } catch (Exception) { throw; } }