public async Task <ApiResult <List <GetListVipOwnerCertificationConditionOutpu> > > GetList(CancellationToken cancelToken) { if (Authorization == null) { return(new ApiResult <List <GetListVipOwnerCertificationConditionOutpu> >(APIResultCode.Unknown, new List <GetListVipOwnerCertificationConditionOutpu> { }, APIResultMessage.TokenNull)); } var user = _tokenRepository.GetUser(Authorization); if (user == null) { return(new ApiResult <List <GetListVipOwnerCertificationConditionOutpu> >(APIResultCode.Unknown, new List <GetListVipOwnerCertificationConditionOutpu> { }, APIResultMessage.TokenError)); } var data = await _vipOwnerCertificationConditionRepository.GetListAsync(cancelToken); return(new ApiResult <List <GetListVipOwnerCertificationConditionOutpu> >(APIResultCode.Success, data.Select(x => new GetListVipOwnerCertificationConditionOutpu { Id = x.Id.ToString(), Description = x.Description, Title = x.Title, TypeName = x.TypeName, TypeValue = x.TypeValue }).ToList())); }
public async Task <ApiResult <AddVipOwnerApplicationOutput> > Add([FromBody] AddVipOwnerApplicationRecordInput input, CancellationToken cancelToken) { if (Authorization == null) { return(new ApiResult <AddVipOwnerApplicationOutput>(APIResultCode.Unknown, new AddVipOwnerApplicationOutput { }, APIResultMessage.TokenNull)); } if (string.IsNullOrWhiteSpace(input.StructureId)) { throw new NotImplementedException("职能Id信息为空!"); } if (string.IsNullOrWhiteSpace(input.OwnerCertificationId)) { throw new NotImplementedException("业主认证Id信息为空!"); } if (input.Models.Count < 3) { throw new NotImplementedException("提交申请凭证信息不准确!"); } var data = await _vipOwnerCertificationConditionRepository.GetListAsync(cancelToken); foreach (var item in data) { var entity = input.Models.Where(x => x.ConditionId == item.Id.ToString()).FirstOrDefault(); if (string.IsNullOrWhiteSpace(entity?.AnnexContent)) { throw new NotImplementedException("提交" + item.Title + "申请凭证信息不准确!"); } } var user = _tokenRepository.GetUser(Authorization); if (user == null) { return(new ApiResult <AddVipOwnerApplicationOutput>(APIResultCode.Unknown, new AddVipOwnerApplicationOutput { }, APIResultMessage.TokenError)); } var vipOwnerApplicationRecord = await _vipOwnerApplicationRecordRepository.AddAsync(new VipOwnerApplicationRecordDto { StructureId = input.StructureId, OperationUserId = user.Id.ToString(), SmallDistrictId = input.SmallDistrictId, Reason = input.Reason, OperationTime = DateTimeOffset.Now, UserId = user.Id.ToString(), OwnerCertificationId = input.OwnerCertificationId }, cancelToken); foreach (var item in input.Models) { await _vipOwnerCertificationAnnexRepository.AddAsync(new VipOwnerCertificationAnnexDto { ApplicationRecordId = vipOwnerApplicationRecord.Id.ToString(), CertificationConditionId = item.ConditionId, AnnexContent = item.AnnexContent, OperationTime = DateTimeOffset.Now, OperationUserId = user.Id.ToString() }); } return(new ApiResult <AddVipOwnerApplicationOutput>(APIResultCode.Success, new AddVipOwnerApplicationOutput { Id = vipOwnerApplicationRecord.Id.ToString() }, APIResultMessage.Success)); }