public IEnumerable <ParentSimpleViewDTO> GetAll()
        {
            var parents = db.ParentsRepository.Get();

            logger.Info("Getting all entries of type {0}", parents.GetType());

            return(parents
                   .Select(x => UserToUserDTOConverters.ParentToParentSimpleViewDTO(x)));
        }
Exemplo n.º 2
0
        public IEnumerable <ParentSimpleViewDTO> GetAllParents()
        {
            IEnumerable <Parent> users = db.ParentsRepository.Get();

            logger.Info("Getting all parents.");

            IEnumerable <ParentSimpleViewDTO> retVal = users.Select(x => UserToUserDTOConverters.ParentToParentSimpleViewDTO(x));

            return(retVal);
        }
        public ParentSimpleViewDTO GetById(string id)
        {
            Parent parent = db.ParentsRepository.GetByID(id);

            logger.Info("Getting parent with id {0}.", id);

            if (parent == null || !(parent is Parent))
            {
                logger.Error("Parent with id {0} does not exist. Throwing key not found exception.", id);
                throw new KeyNotFoundException();
            }

            return(UserToUserDTOConverters.ParentToParentSimpleViewDTO(parent));
        }
Exemplo n.º 4
0
        public ParentSimpleViewDTO GetParentById(string id)
        {
            Parent parent = db.ParentsRepository.Get(p => p.Id == id).FirstOrDefault();

            if (parent == null)
            {
                logger.Warn("No such parent. {0}", id);
                return(null);
            }
            logger.Info("Getting parent with id {0}", id);

            ParentSimpleViewDTO retVal = UserToUserDTOConverters.ParentToParentSimpleViewDTO(parent);

            return(retVal);
        }
        public IEnumerable <ParentSimpleViewDTO> GetAllByNumberOfChildren(int numberOfChildern)
        {
            //TODO 11.16 **DONE** exception if number of children < 1
            if (numberOfChildern < 1)
            {
                logger.Error("Cannot have {0} children! Throwing ArgumentOutOfRangeException.", numberOfChildern);

                throw new ArgumentOutOfRangeException("Can't have less than 1 child!", new ArgumentOutOfRangeException());
            }

            var parents = db.ParentsRepository
                          .Get(p => p.Students.Count() == numberOfChildern);

            logger.Info("Getting parents with {0} children.", numberOfChildern);

            return(parents.
                   Select(x => UserToUserDTOConverters.ParentToParentSimpleViewDTO(x)));
        }
        public IEnumerable <ParentSimpleViewDTO> GetAllByChildrenClass(int schoolClassId)
        {
            //TODO 11.13: **DONE** exception if school class id nonexistant
            var sc = db.SchoolClassesRepository.GetByID(schoolClassId);

            if (sc == null)
            {
                logger.Error("schoolClassId with value {0} not found. Throwing KeyNotFoundException.", schoolClassId);
                throw new KeyNotFoundException("That school class does not exist.");
            }

            var parents = db.ParentsRepository
                          .Get(p => p.Students.Any(s => s.SchoolClass.Id == schoolClassId));

            logger.Info("Getting parents with childern schoolClassId {0}.", schoolClassId);

            return(parents
                   .Select(x => UserToUserDTOConverters.ParentToParentSimpleViewDTO(x)));
        }