Example #1
0
        public StudentWithParentGradesClassDTO GetById(string id)
        {
            Student student = db.StudentsRepository.GetByID(id);

            if (student == null || !(student is Student))
            {
                logger.Error("Student with id {0} not found, or of a wrong user type. Throwing KeyNotFoundException.", id);
                throw new KeyNotFoundException();
            }

            logger.Info("Getting student with id {0}", id);
            return(UserToUserDTOConverters.StudentToStudentWithParentGradesClassDTO(student));
        }
Example #2
0
        public StudentWithParentGradesClassDTO GetByIdAndParentId(string studentId, string parentId)
        {
            Student student = db.StudentsRepository.GetByID(studentId);

            if (student == null || !(student is Student))
            {
                logger.Error("Student with id {0} not found, or of a wrong user type. Throwing KeyNotFoundException.", studentId);
                throw new KeyNotFoundException();
            }

            if (student.Parent.Id != parentId)
            {
                logger.Error("student {0} {1} is not child of parent with id {2}", student.FirstName, student.LastName, parentId);
                throw new ArgumentException("That is not your child!");
            }

            logger.Info("Getting StudentId {0}, child of {1}", studentId, parentId);
            return(UserToUserDTOConverters.StudentToStudentWithParentGradesClassDTO(student));
        }