Skip to content

Commit

Permalink
remove "previousDocument must be within previous application" cretier…
Browse files Browse the repository at this point in the history
…ia (#2072)

# Description

This PR includes the following proposed change(s):

- remove "previousDocument must be within previous application"
cretieria
  • Loading branch information
peggy-quartech authored Jan 9, 2025
1 parent 748bc1e commit 89d5df2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
18 changes: 10 additions & 8 deletions src/Spd.Manager.Licence/LicenceAppManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,19 @@ protected IEnumerable<UploadedDocumentEnum> GetUploadedDocumentEnumsFromDocument

protected async Task<IList<LicAppFileInfo>> GetExistingFileInfo(Guid? originalApplicationId, IEnumerable<Guid>? previousDocumentIds, CancellationToken ct)
{
DocumentListResp docListResps = await _documentRepository.QueryAsync(new DocumentQry(originalApplicationId), ct);
IList<LicAppFileInfo> existingFileInfos = Array.Empty<LicAppFileInfo>();
IList<LicAppFileInfo> existingFileInfos = new List<LicAppFileInfo>();

if (previousDocumentIds != null && docListResps != null)
if (previousDocumentIds != null && previousDocumentIds.Any())
{
existingFileInfos = docListResps.Items.Where(d => previousDocumentIds.Contains(d.DocumentUrlId) && d.DocumentType2 != null)
.Select(f => new LicAppFileInfo()
foreach (var documentId in previousDocumentIds)
{
FileName = f.FileName ?? String.Empty,
LicenceDocumentTypeCode = (LicenceDocumentTypeCode)Mappings.GetLicenceDocumentTypeCode(f.DocumentType, f.DocumentType2),
}).ToList();
var resp = await _documentRepository.GetAsync(documentId, ct);
existingFileInfos.Add(new LicAppFileInfo()
{
FileName = resp.FileName ?? String.Empty,
LicenceDocumentTypeCode = (LicenceDocumentTypeCode)Mappings.GetLicenceDocumentTypeCode(resp.DocumentType, resp.DocumentType2),
});
}
}
return existingFileInfos;
}
Expand Down
15 changes: 2 additions & 13 deletions src/Spd.Manager.Licence/PermitAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public async Task<PermitAppCommandResponse> Handle(PermitAppRenewCommand cmd, Ca
cancellationToken);
await ValidateFilesForRenewUpdateAppAsync(cmd.LicenceAnonymousRequest,
cmd.LicAppFileInfos.ToList(),
existingFiles,
cancellationToken);

CreateLicenceApplicationCmd createApp = _mapper.Map<CreateLicenceApplicationCmd>(request);
Expand Down Expand Up @@ -404,21 +405,9 @@ private async Task<ChangeSpec> MakeChanges(LicenceResp originalLic,

private async Task ValidateFilesForRenewUpdateAppAsync(PermitAppSubmitRequest request,
IList<LicAppFileInfo> newFileInfos,
IList<LicAppFileInfo> existingFileInfos,
CancellationToken ct)
{
DocumentListResp docListResps = await _documentRepository.QueryAsync(new DocumentQry(request.OriginalApplicationId), ct);
IList<LicAppFileInfo> existingFileInfos = Array.Empty<LicAppFileInfo>();

if (request.PreviousDocumentIds != null)
{
existingFileInfos = docListResps.Items.Where(d => request.PreviousDocumentIds.Contains(d.DocumentUrlId) && d.DocumentType2 != null)
.Select(f => new LicAppFileInfo()
{
FileName = f.FileName ?? String.Empty,
LicenceDocumentTypeCode = (LicenceDocumentTypeCode)Mappings.GetLicenceDocumentTypeCode(f.DocumentType, f.DocumentType2),
}).ToList();
}

if (request.HasLegalNameChanged == true && !newFileInfos.Any(f => f.LicenceDocumentTypeCode == LicenceDocumentTypeCode.LegalNameChange))
{
throw new ApiException(HttpStatusCode.BadRequest, "Missing LegalNameChange file");
Expand Down

0 comments on commit 89d5df2

Please sign in to comment.