public void ValidateNoDuplicates(Teacher info, bool isNew = true)
 {
     using (var dao = new TeacherDAO())
     {
         var query = isNew ? dao.Query(e => true) : dao.Query(e => e.ID != info.ID);
         var qName = query.Where(e => e.NOMBRE == info.Name);
         if (qName.Any())
         {
             var qLastName = query.Where(e => e.APELLIDOS == info.LastName);
             if (qLastName.Any())
             {
                 throw new Exception(Common.Constants.Messages.PROFESOR_NOMBRE_REPETIDO);
             }
         }
     }
 }
 public Teacher GetByID(int IDd)
 {
     using (var dao = new TeacherDAO())
     {
         var query = dao.Query(e => true);
         return(query.Where(e => e.ID == IDd).First().Map());
     }
 }
Beispiel #3
0
 public void ValidateTeacher(Course info)
 {
     using (var dao = new TeacherDAO())
     {
         var query    = dao.Query(e => true);
         var qTeacher = query.Where(e => e.ID == info.Teacher.ID);
         if (!qTeacher.Any())
         {
             throw new Exception(Common.Constants.Messages.PROFESOR_NO_ENCONTRADO);
         }
     }
 }
 public List <Teacher> Get(string text)
 {
     using (var dao = new TeacherDAO())
     {
         var query = dao.Query(e => true);
         if (!string.IsNullOrWhiteSpace(text))
         {
             query = query.Where(e => e.NOMBRE.Contains(text));
         }
         return(query.ToArray().Select(e => e.Map()).ToList());
     }
 }
Beispiel #5
0
        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());
                }
            }
        }
Beispiel #6
0
 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);
                 }
             }
         }
     }
 }
Beispiel #7
0
        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());
                }
            }
        }