コード例 #1
0
        public IActionResult Get(string fields, TQueryParameters queryParams)
        {
            if (typeCheckerHelper.CheckIfTypeHasPoperties(fields, typeof(TDto)))
            {
                return(new BadRequestResult());
            }

            var fromRepo = repository.Get(queryParams);
            IEnumerable <TDto> mapped = Mapper.Map <IEnumerable <TDto> >(fromRepo);

            return(new OkObjectResult(mapped.ShapeData(fields)));
        }
コード例 #2
0
        public IActionResult GetParents([FromQuery] ParentQueryParameters parentQuery)
        {
            if (!typeCheckerHelper.CheckIfTypeHasPoperties(parentQuery.Fields, typeof(ParentDto)))
            {
                return(BadRequest());
            }

            var parentsFromRepo = parentRepo.GetParent(parentQuery);

            IEnumerable <ParentDto> cl = Mapper.Map <IEnumerable <ParentDto> >(parentsFromRepo);

            return(Ok(cl.ShapeData(parentQuery.Fields)));
        }
コード例 #3
0
        public IActionResult GetSubjects([FromQuery] SubjectQueryParameters subjects)
        {
            if (!typeCheckerHelper.CheckIfTypeHasPoperties(subjects.Fields, typeof(SubjectDto)))
            {
                return(BadRequest());
            }

            var subjectsFromRepo = subjectRepository.GetSubjects(subjects);

            IEnumerable <SubjectDto> sb = Mapper.Map <IEnumerable <SubjectDto> >(subjectsFromRepo);

            return(Ok(sb.ShapeData(subjects.Fields)));
        }
コード例 #4
0
        public IActionResult GetTeachers([FromQuery] TeacherQueryParameters teacherQuery)
        {
            if (!typeCheckerHelper.CheckIfTypeHasPoperties(teacherQuery.Fields, typeof(TeacherDto)))
            {
                return(BadRequest());
            }

            var teachersFromRepo = teacherRepo.GetTeachers(teacherQuery);

            IEnumerable <TeacherDto> t = Mapper.Map <IEnumerable <TeacherDto> >(teachersFromRepo);

            return(Ok(t.ShapeData(teacherQuery.Fields)));
        }
コード例 #5
0
        public IActionResult GetStudents([FromQuery] StudentQueryParameters studentResourceParameters)
        {
            if (!typeChecker.CheckIfTypeHasPoperties(studentResourceParameters.Fields, typeof(StudentDto)))
            {
                return(BadRequest());
            }

            // Get data from repository (including sorting and filtering)
            var studentsFromRepo = studentsRepo.GetStudents(studentResourceParameters);

            // Map from Students enitty to StudentsDto
            IEnumerable <StudentDto> students = Mapper.Map <IEnumerable <StudentDto> >(studentsFromRepo);

            // Perform data shaping and return value
            return(Ok(students.ShapeData(studentResourceParameters.Fields)));
        }