Пример #1
0
        public IEnumerable <TeacherBasicDTO> GetAll()
        {
            var retVal = db.TeachersRepository.Get();

            logger.Info("Getting all teachers.");
            return(retVal.Select(x => UserToUserDTOConverters.TeacherToTeacherBasicDTO(x)));
        }
Пример #2
0
        public TeacherBasicDTO GetById(string id)
        {
            var retVal = db.TeachersRepository.GetByID(id);

            logger.Info("Getting teacher with id {0}", id);
            return(UserToUserDTOConverters.TeacherToTeacherBasicDTO(retVal));
        }
Пример #3
0
        public IEnumerable <TeacherBasicDTO> GetAllTeachingToStudent(string id)
        {
            var retVal = db.TeachersRepository.Get()
                         .Where(x => x.TeacherSchoolSubjects.Any(y => y.SchoolClassTeacherSchoolSubjects.Any(z => z.SchoolClass.Students.Any(a => a.Id == id))));

            logger.Info("Getting all teachers teaching to student with id {0}.", id);
            return(retVal.Select(x => UserToUserDTOConverters.TeacherToTeacherBasicDTO(x)));
        }
Пример #4
0
        public IEnumerable <TeacherBasicDTO> GetAllTeachingToClass(int id)
        {
            var retVal = db.TeachersRepository.Get()
                         .Where(x => x.TeacherSchoolSubjects.Any(y => y.SchoolClassTeacherSchoolSubjects.Any(z => z.SchoolClass.Id == id)));

            if (retVal == null)
            {
                logger.Error("Class with id {0} is non existant.", id);
                throw new ArgumentException("No class with that id.");
            }

            logger.Info("Getting teachers teaching to a class with id {0}", id);
            return(retVal.Select(x => UserToUserDTOConverters.TeacherToTeacherBasicDTO(x)));
        }
Пример #5
0
        public IEnumerable <TeacherBasicDTO> GetAllTeachingToAGrade(int grade)
        {
            var retVal = db.TeachersRepository.Get()
                         .Where(x => x.TeacherSchoolSubjects.Any(y => y.SchoolClassTeacherSchoolSubjects.Any(z => z.SchoolClass.SchoolGrade == grade)));

            if (retVal == null)
            {
                logger.Error("No teachers assinged to {0} grade.", grade);
                throw new ArgumentException("No teachers teach to that grade.");
            }

            logger.Info("Getting teachers teaching to {0}th grade.", grade);
            return(retVal.Select(x => UserToUserDTOConverters.TeacherToTeacherBasicDTO(x)));
        }
Пример #6
0
        public IEnumerable <TeacherBasicDTO> GetAllBySubjectName(string name)
        {
            if (name == null)
            {
                throw new NullReferenceException();
            }

            var retVal = db.TeachersRepository.Get()
                         .Where(x => x.TeacherSchoolSubjects.Any(y => y.SchoolSubject.Name.ToLower().Contains(name.ToLower())));

            if (retVal == null)
            {
                logger.Warn("No teachers teaching subject with name containg \"{0}\" exist.", name);
                throw new ArgumentException("No teachers teaching subject with name containing that string.");
            }

            logger.Info("Getting teachers teaching subjects with names containing \"{0}\"", name);
            return(retVal.Select(x => UserToUserDTOConverters.TeacherToTeacherBasicDTO(x)));
        }
Пример #7
0
        public IEnumerable <TeacherBasicDTO> GetAllByName(string name)
        {
            if (name == null)
            {
                throw new NullReferenceException();
            }

            var retVal = db.TeachersRepository.Get()
                         .Where(x => (x.FirstName + " " + x.LastName).ToLower().Contains(name.ToLower()));

            if (retVal == null)
            {
                logger.Warn("Teacher with name and surname containing \"{0}\" is non existant.", name);
                throw new ArgumentException("No teacher with name and surname containing that string.");
            }

            logger.Info("Getting teachers with names and/or surnames containing \"{0}\"", name);
            return(retVal.Select(x => UserToUserDTOConverters.TeacherToTeacherBasicDTO(x)));
        }