Пример #1
0
        public async Task <ApiResult <GetListOwnerCertificationRecordOutput> > GetAllForSmallDistrictId([FromUri] string SmallDistrictId, CancellationToken cancelToken)
        {
            if (Authorization == null)
            {
                return(new ApiResult <GetListOwnerCertificationRecordOutput>(APIResultCode.Unknown, new GetListOwnerCertificationRecordOutput {
                }, APIResultMessage.TokenNull));
            }

            var user = _tokenRepository.GetUser(Authorization);

            if (user == null)
            {
                return(new ApiResult <GetListOwnerCertificationRecordOutput>(APIResultCode.Unknown, new GetListOwnerCertificationRecordOutput {
                }, APIResultMessage.TokenError));
            }
            var data = await _ownerCertificationRecordRepository.GetAllForSmallDistrictIdIncludeAsync(new OwnerCertificationRecordDto
            {
                UserId          = user.Id.ToString(),
                SmallDistrictId = SmallDistrictId
            }, cancelToken);

            List <GetOwnerCertificationRecordOutput> list = new List <GetOwnerCertificationRecordOutput>();

            foreach (var item in data)
            {
                var owner = await _ownerRepository.GetAsync(item.OwnerId.ToString(), cancelToken);

                var industry = await _industryRepository.GetAsync(item.IndustryId.ToString(), cancelToken);

                list.Add(new GetOwnerCertificationRecordOutput
                {
                    BuildingId               = item.Industry.BuildingUnit.BuildingId.ToString(),
                    BuildingName             = item.Industry.BuildingUnit.Building.Name,
                    BuildingUnitId           = item.Industry.BuildingUnitId.ToString(),
                    BuildingUnitName         = item.Industry.BuildingUnit.UnitName,
                    CertificationResult      = item.CertificationResult,
                    CertificationStatusName  = item.CertificationStatusName,
                    CertificationStatusValue = item.CertificationStatusValue,
                    CertificationTime        = item.CreateOperationTime.ToString(),
                    CommunityId              = item.Industry.BuildingUnit.Building.SmallDistrict.CommunityId.ToString(),
                    CommunityName            = item.Industry.BuildingUnit.Building.SmallDistrict.Community.Name,
                    Id                = item.Id.ToString(),
                    IndustryId        = item.IndustryId.ToString(),
                    IndustryName      = item.Industry.Name,
                    OwnerId           = item.OwnerId.ToString(),
                    OwnerName         = item.Owner.Name,
                    SmallDistrictId   = item.Industry.BuildingUnit.Building.SmallDistrictId.ToString(),
                    SmallDistrictName = item.Industry.BuildingUnit.Building.SmallDistrict.Name,
                    StreetOfficeId    = item.Industry.BuildingUnit.Building.SmallDistrict.Community.StreetOfficeId.ToString(),
                    StreetOfficeName  = item.Industry.BuildingUnit.Building.SmallDistrict.Community.StreetOffice.Name,
                    UserId            = item.UserId,
                    Name              = owner?.Name,
                    Birthday          = owner?.Birthday,
                    Gender            = owner?.Gender,
                    IDCard            = owner?.IDCard,
                    PhoneNumber       = owner?.PhoneNumber,
                    NumberOfLayers    = industry?.NumberOfLayers,
                    Acreage           = industry?.Acreage
                });
            }
            return(new ApiResult <GetListOwnerCertificationRecordOutput>(APIResultCode.Success, new GetListOwnerCertificationRecordOutput
            {
                List = list
            }));
        }