Beispiel #1
0
 public GetPersonInfoRelationDto Map(Relation source)
 {
     return(new GetPersonInfoRelationDto
     {
         Id = source.Id,
         TypeId = source.RelationTypeId,
         TypeName = source.RelationType.Name,
         Person = _relatedPersonMapper.Map(source.PersonTo)
     });
 }
Beispiel #2
0
 public GetPersonInfoDto Map(Person source)
 {
     return(new GetPersonInfoDto
     {
         Id = source.Id,
         BirthDate = source.BirthDate,
         CityId = source.CityId,
         CityName = source.City.Name,
         FirstName = source.Name.FirstName,
         GenderTypeId = source.GenderTypeId,
         GenderTypeName = source.GenderType?.Name,
         LastName = source.Name.LastName,
         PersonalNumber = source.PersonalNumber,
         ImagePath = !string.IsNullOrWhiteSpace(source.ImagePath) ? Path.Combine(_photoUploadService.GetWebRootPath(), source.ImagePath) : null,
         PhoneNumbers = source.PhoneNumbers.Select(p => _phoneNumberMapper.Map(p)),
         Relations = source.DirectRelatedPersons.Select(r => _relationMapper.Map(r)),
     });
 }
Beispiel #3
0
        public async Task <GetPersonInfoDto> Handle(GetPersonInfoQuery request, CancellationToken cancellationToken)
        {
            var data = await _context.Person.Where(x => x.Id == request.PersonId)
                       .Include(x => x.City)
                       .Include(x => x.GenderType)
                       .Include(x => x.PhoneNumbers)
                       .ThenInclude(x => x.PhoneNumberType)

                       .Include(x => x.DirectRelatedPersons)
                       .ThenInclude(x => x.RelationType)

                       .Include(x => x.DirectRelatedPersons)
                       .ThenInclude(x => x.PersonTo)
                       .ThenInclude(x => x.City)

                       .Include(x => x.DirectRelatedPersons)
                       .ThenInclude(x => x.PersonTo)
                       .ThenInclude(x => x.GenderType)

                       .Include(x => x.DirectRelatedPersons)
                       .ThenInclude(x => x.PersonTo)
                       .ThenInclude(x => x.PhoneNumbers)
                       .ThenInclude(x => x.PhoneNumberType)

                       .OrderBy(x => x.Id)
                       .Select(x => _customMapper.Map(x))
                       .AsNoTracking()
                       .SingleOrDefaultAsync(cancellationToken);

            if (data == default(GetPersonInfoDto))
            {
                throw new ApplicationMessageException(ApplicationExceptionCode.PersonNotFound);
            }

            return(data);
        }