Skip to content

Commit 89d5df2

Browse files
remove "previousDocument must be within previous application" cretieria (#2072)
# Description This PR includes the following proposed change(s): - remove "previousDocument must be within previous application" cretieria
1 parent 748bc1e commit 89d5df2

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

src/Spd.Manager.Licence/LicenceAppManagerBase.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,19 @@ protected IEnumerable<UploadedDocumentEnum> GetUploadedDocumentEnumsFromDocument
312312

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

318-
if (previousDocumentIds != null && docListResps != null)
317+
if (previousDocumentIds != null && previousDocumentIds.Any())
319318
{
320-
existingFileInfos = docListResps.Items.Where(d => previousDocumentIds.Contains(d.DocumentUrlId) && d.DocumentType2 != null)
321-
.Select(f => new LicAppFileInfo()
319+
foreach (var documentId in previousDocumentIds)
322320
{
323-
FileName = f.FileName ?? String.Empty,
324-
LicenceDocumentTypeCode = (LicenceDocumentTypeCode)Mappings.GetLicenceDocumentTypeCode(f.DocumentType, f.DocumentType2),
325-
}).ToList();
321+
var resp = await _documentRepository.GetAsync(documentId, ct);
322+
existingFileInfos.Add(new LicAppFileInfo()
323+
{
324+
FileName = resp.FileName ?? String.Empty,
325+
LicenceDocumentTypeCode = (LicenceDocumentTypeCode)Mappings.GetLicenceDocumentTypeCode(resp.DocumentType, resp.DocumentType2),
326+
});
327+
}
326328
}
327329
return existingFileInfos;
328330
}

src/Spd.Manager.Licence/PermitAppManager.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public async Task<PermitAppCommandResponse> Handle(PermitAppRenewCommand cmd, Ca
191191
cancellationToken);
192192
await ValidateFilesForRenewUpdateAppAsync(cmd.LicenceAnonymousRequest,
193193
cmd.LicAppFileInfos.ToList(),
194+
existingFiles,
194195
cancellationToken);
195196

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

405406
private async Task ValidateFilesForRenewUpdateAppAsync(PermitAppSubmitRequest request,
406407
IList<LicAppFileInfo> newFileInfos,
408+
IList<LicAppFileInfo> existingFileInfos,
407409
CancellationToken ct)
408410
{
409-
DocumentListResp docListResps = await _documentRepository.QueryAsync(new DocumentQry(request.OriginalApplicationId), ct);
410-
IList<LicAppFileInfo> existingFileInfos = Array.Empty<LicAppFileInfo>();
411-
412-
if (request.PreviousDocumentIds != null)
413-
{
414-
existingFileInfos = docListResps.Items.Where(d => request.PreviousDocumentIds.Contains(d.DocumentUrlId) && d.DocumentType2 != null)
415-
.Select(f => new LicAppFileInfo()
416-
{
417-
FileName = f.FileName ?? String.Empty,
418-
LicenceDocumentTypeCode = (LicenceDocumentTypeCode)Mappings.GetLicenceDocumentTypeCode(f.DocumentType, f.DocumentType2),
419-
}).ToList();
420-
}
421-
422411
if (request.HasLegalNameChanged == true && !newFileInfos.Any(f => f.LicenceDocumentTypeCode == LicenceDocumentTypeCode.LegalNameChange))
423412
{
424413
throw new ApiException(HttpStatusCode.BadRequest, "Missing LegalNameChange file");

0 commit comments

Comments
 (0)