public List <CourseStudent> Get() { using (var dao = new CourseStudentDAO()) { var query = dao.Query(e => true); var coursesstudents = query.ToArray(); var cuenta3 = coursesstudents.Length; using (var courdao = new CourseDAO()) { var ids = coursesstudents.Select(e => e.IDCURSO).Distinct(); var courses = courdao.Query(e => ids.Contains(e.ID)).ToArray(); var cuenta2 = courses.Length; using (var studendao = new StudentDAO()) { var ids2 = coursesstudents.Select(e => e.IDESTUDIANTE).Distinct(); var students = studendao.Query(e => ids2.Contains(e.ID)).ToArray(); var cuenta = students.Length; return(coursesstudents.Select(e => e.Map(students, courses)).ToList()); } } } }
public void ValidateCourse(CourseStudent info) { using (var dao = new CourseDAO()) { var query = dao.Query(e => true); var qCourse = query.Where(e => e.ID == info.Course.ID); if (!qCourse.Any()) { throw new Exception(Common.Constants.Messages.CURSO_NO_ENCONTRADO); } } }
public void ValidateNoTeacherInstan(Teacher info) { using (var dao = new CourseDAO()) { var query = dao.Query(e => true); var qCourse = query.Where(e => e.IDPROFESOR == info.ID).ToList(); if (qCourse.Any()) { throw new Exception(Common.Constants.Messages.PROFESOR_CON_CURSOS); } } }
public Course GetByID(int IDd) { using (var dao = new CourseDAO()) { var query = dao.Query(e => true); var courses = query.ToArray(); using (var teaDAO = new TeacherDAO()) { var ids = courses.Select(e => e.IDPROFESOR).Distinct(); var teachers = teaDAO.Query(e => e.ID == IDd).ToArray(); return(courses.Select(e => e.Map(teachers)).First()); } } }
public void ValidateMaxTeacherCourses(Course info) { using (var dao = new TeacherDAO()) { var query = dao.Query(e => true); var qTeacher = query.Where(e => e.ID == info.Teacher.ID).First().Map(); if (!qTeacher.HasPlaza) { using (var coursedao = new CourseDAO()) { var coursequery = coursedao.Query(e => true); var qCourse = coursequery.Where(e => e.IDPROFESOR == info.Teacher.ID).ToArray(); if (qCourse.Length >= Common.Constants.Constants.MAX_TEACHER_CURSOS) { throw new Exception(Common.Constants.Messages.PROFESOR_MAXIMO_MATERIAS); } } } } }
public List <Course> Get(string text) { using (var dao = new CourseDAO()) { var query = dao.Query(e => true); if (!string.IsNullOrWhiteSpace(text)) { query = query.Where(e => e.NOMBRE.Contains(text)); } var courses = query.ToArray(); var coursesLe = courses.Length; using (var teadao = new TeacherDAO()) { var ids = courses.Select(e => e.IDPROFESOR).Distinct(); var teachers = teadao.Query(e => ids.Contains(e.ID)).ToArray(); return(courses.Select(e => e.Map(teachers)).ToList()); } } }
//[Authorize] public List <Course> GetAll() { return(CourseDAO.Query()); }