Пример #1
0
        public async Task <IEnumerable <StudentDto> > HandleAsync(GetAllStudentsRequest request,
                                                                  CancellationToken cancellationToken = default)
        {
            var studentTypes = await _studentTypeRepository.GetAllAsync(cancellationToken);

            var temp        = (await _studentRepository.GetAllAsync(cancellationToken: cancellationToken)).ToList();
            var studentDtos = _mapper.Map <IEnumerable <StudentDto> >(temp);

            foreach (var studentDto in studentDtos)
            {
                studentDto.StudentType = studentTypes.First(f => f.StudentTypeId == studentDto.StudentTypeId).Description;
            }
            return(studentDtos);
        }
Пример #2
0
        public async Task <IEnumerable <StudentDto> > HandleAsync(GetAllStudentsRequest request,
                                                                  CancellationToken cancellationToken = default)
        {
            var students    = (await _studentRepository.GetAllAsync(cancellationToken: cancellationToken)).ToList();
            var studentDtos = from s in students
                              select new StudentDto
            {
                Id          = s.Id,
                FirstName   = s.FirstName,
                LastName    = s.LastName,
                StudentType = s.StudentType
            };

            return(studentDtos);
        }