Esempio n. 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)));
        }
Esempio n. 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)));
        }
Esempio n. 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)));
        }
Esempio n. 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)));
        }
Esempio n. 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)));
        }