From 89d5df248e457fd1892a19b5f20b8c472a764991 Mon Sep 17 00:00:00 2001 From: Peggy Date: Thu, 9 Jan 2025 15:21:45 -0800 Subject: [PATCH] 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 --- .../LicenceAppManagerBase.cs | 18 ++++++++++-------- src/Spd.Manager.Licence/PermitAppManager.cs | 15 ++------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/Spd.Manager.Licence/LicenceAppManagerBase.cs b/src/Spd.Manager.Licence/LicenceAppManagerBase.cs index 237153897..63b0db4b6 100644 --- a/src/Spd.Manager.Licence/LicenceAppManagerBase.cs +++ b/src/Spd.Manager.Licence/LicenceAppManagerBase.cs @@ -312,17 +312,19 @@ protected IEnumerable GetUploadedDocumentEnumsFromDocument protected async Task> GetExistingFileInfo(Guid? originalApplicationId, IEnumerable? previousDocumentIds, CancellationToken ct) { - DocumentListResp docListResps = await _documentRepository.QueryAsync(new DocumentQry(originalApplicationId), ct); - IList existingFileInfos = Array.Empty(); + IList existingFileInfos = new List(); - 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; } diff --git a/src/Spd.Manager.Licence/PermitAppManager.cs b/src/Spd.Manager.Licence/PermitAppManager.cs index b47d81e52..5a39208f6 100644 --- a/src/Spd.Manager.Licence/PermitAppManager.cs +++ b/src/Spd.Manager.Licence/PermitAppManager.cs @@ -191,6 +191,7 @@ public async Task Handle(PermitAppRenewCommand cmd, Ca cancellationToken); await ValidateFilesForRenewUpdateAppAsync(cmd.LicenceAnonymousRequest, cmd.LicAppFileInfos.ToList(), + existingFiles, cancellationToken); CreateLicenceApplicationCmd createApp = _mapper.Map(request); @@ -404,21 +405,9 @@ private async Task MakeChanges(LicenceResp originalLic, private async Task ValidateFilesForRenewUpdateAppAsync(PermitAppSubmitRequest request, IList newFileInfos, + IList existingFileInfos, CancellationToken ct) { - DocumentListResp docListResps = await _documentRepository.QueryAsync(new DocumentQry(request.OriginalApplicationId), ct); - IList existingFileInfos = Array.Empty(); - - 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");