Exemple #1
0
        public async Task <ActionResult <ProfessionDto> > GetProfession(Guid professionId)
        {
            var profession = await _professionRepository.GetProfessionAsync(professionId);

            profession.Academy = await _academyRepository.GetAcademyAsync(profession.AcademyId);

            if (profession == null)
            {
                throw new ArgumentNullException(nameof(profession));
            }
            var professionDto = _mapper.Map <ProfessionDto>(profession);

            return(Ok(professionDto));
        }
        public async Task <ActionResult <IEnumerable <StudentDto> > > GetStudents([FromQuery] StudentDtoParameters studentDtoParameters)
        {
            var students = await _studentRepository.GetStudentsAsync(studentDtoParameters);

            foreach (var student in students)
            {
                student.Profession = await _professionRepository.GetProfessionAsync(student.ProfessionId);

                student.Profession.Academy = await _academyRepository.GetAcademyAsync(student.Profession.AcademyId);
            }
            var studentDtos = _mapper.Map <IEnumerable <StudentDto> >(students);

            return(Ok(studentDtos));
        }