From afc62cd19f5008f6032bd61abe0b38267491508e Mon Sep 17 00:00:00 2001 From: peggy-quartech Date: Thu, 17 Oct 2024 15:40:38 -0700 Subject: [PATCH 1/2] code --- .../LicenceAppManagerBase.cs | 1 + src/Spd.Manager.Licence/LicenceManager.cs | 19 +++++++------------ .../Licence/LicenceRepository.cs | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Spd.Manager.Licence/LicenceAppManagerBase.cs b/src/Spd.Manager.Licence/LicenceAppManagerBase.cs index dc2bd619c..4918d474a 100644 --- a/src/Spd.Manager.Licence/LicenceAppManagerBase.cs +++ b/src/Spd.Manager.Licence/LicenceAppManagerBase.cs @@ -66,6 +66,7 @@ protected async Task CommitApplicationAsync(LicenceAppBase licAppBase, //companionAppId is the swl for sole proprietor which the business would pay for it, therefore the licence fee should be null here. if (companionAppId != null) { + await MoveFilesAsync((Guid)companionAppId, ct); await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, null, ct); } // Commit the main licence application diff --git a/src/Spd.Manager.Licence/LicenceManager.cs b/src/Spd.Manager.Licence/LicenceManager.cs index 2e096ef05..8571a0949 100644 --- a/src/Spd.Manager.Licence/LicenceManager.cs +++ b/src/Spd.Manager.Licence/LicenceManager.cs @@ -110,22 +110,17 @@ public async Task> Handle(LicenceListQuery que public async Task Handle(LicencePhotoQuery query, CancellationToken cancellationToken) { //find contact id through licenceId - LicenceListResp lic = await _licenceRepository.QueryAsync(new LicenceQry() { LicenceId = query.LicenceId }, cancellationToken); - Guid? applicantId = lic.Items.FirstOrDefault()?.LicenceHolderId; - if (applicantId == null) + LicenceResp lic = await _licenceRepository.GetAsync(query.LicenceId, cancellationToken); + if (lic == null) { - throw new ApiException(HttpStatusCode.BadRequest, "cannot find the licence holder."); + throw new ApiException(HttpStatusCode.BadRequest, "cannot find the licence."); } + if (lic.PhotoDocumentUrlId == null) + throw new ApiException(HttpStatusCode.BadRequest, "the licence does not have photo"); - DocumentQry qry = new() - { - ApplicantId = applicantId, - FileType = Enum.Parse(DocumentTypeEnum.Photograph.ToString()), - }; - DocumentListResp docList = await _documentRepository.QueryAsync(qry, cancellationToken); - if (docList == null || !docList.Items.Any()) + DocumentResp? docUrl = await _documentRepository.GetAsync((Guid)lic.PhotoDocumentUrlId, cancellationToken); + if (docUrl == null) return new FileResponse(); - var docUrl = docList.Items.OrderByDescending(f => f.UploadedDateTime).FirstOrDefault(); if (docUrl != null) { diff --git a/src/Spd.Resource.Repository/Licence/LicenceRepository.cs b/src/Spd.Resource.Repository/Licence/LicenceRepository.cs index 567374d9e..f09b281fb 100644 --- a/src/Spd.Resource.Repository/Licence/LicenceRepository.cs +++ b/src/Spd.Resource.Repository/Licence/LicenceRepository.cs @@ -58,7 +58,7 @@ public async Task QueryAsync(LicenceQry qry, CancellationToken lics = lics.Where(d => d.statecode != DynamicsConstants.StateCode_Inactive); if (qry.IncludeInactive) - lics = lics.Where(d => d.statuscode != (int)LicenceStatusOptionSet.Suspended); + lics = lics.Where(d => d.statuscode != (int)LicenceStatusOptionSet.Inactive && d.statuscode != (int)LicenceStatusOptionSet.Suspended); if (qry.LicenceId != null) { From a3454cf5573096500c401feac5cb3711d7c6e417 Mon Sep 17 00:00:00 2001 From: peggy-quartech Date: Thu, 17 Oct 2024 16:14:26 -0700 Subject: [PATCH 2/2] for unauth swl sp --- src/Spd.Manager.Licence/BizLicAppContract.cs | 2 +- src/Spd.Manager.Licence/LicenceAppManagerBase.cs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Spd.Manager.Licence/BizLicAppContract.cs b/src/Spd.Manager.Licence/BizLicAppContract.cs index 1931079f5..8bf5f7f6e 100644 --- a/src/Spd.Manager.Licence/BizLicAppContract.cs +++ b/src/Spd.Manager.Licence/BizLicAppContract.cs @@ -73,7 +73,6 @@ public record BizLicAppResponse : BizLicenceApp public Guid? ExpiredLicenceId { get; set; } public bool? HasExpiredLicence { get; set; } public bool? ApplicantIsBizManager { get; set; } - public ApplicationOriginTypeCode SoleProprietorSWLAppOriginTypeCode { get; set; } // Contains branding, insurance, registrar, security dog certificate and BC report documents public IEnumerable? DocumentInfos { get; set; } @@ -94,6 +93,7 @@ public abstract record BizLicenceApp : LicenceAppBase public bool? AgreeToCompleteAndAccurate { get; set; } public bool? ApplicantIsBizManager { get; set; } public Guid? SoleProprietorSWLAppId { get; set; } //for swl apply for sole proprietor, they need to input swl app id here. + public ApplicationOriginTypeCode? SoleProprietorSWLAppOriginTypeCode { get; set; } public Guid? SubmittedByPortalUserId { get; set; } } diff --git a/src/Spd.Manager.Licence/LicenceAppManagerBase.cs b/src/Spd.Manager.Licence/LicenceAppManagerBase.cs index 4918d474a..2abf24132 100644 --- a/src/Spd.Manager.Licence/LicenceAppManagerBase.cs +++ b/src/Spd.Manager.Licence/LicenceAppManagerBase.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Spd.Manager.Shared; using Spd.Resource.Repository; using Spd.Resource.Repository.Application; using Spd.Resource.Repository.Document; @@ -39,7 +40,12 @@ public LicenceAppManagerBase(IMapper mapper, _licAppRepository = licAppRepository; } - protected async Task CommitApplicationAsync(LicenceAppBase licAppBase, Guid licenceAppId, CancellationToken ct, bool HasSwl90DayLicence = false, Guid? companionAppId = null) + protected async Task CommitApplicationAsync(LicenceAppBase licAppBase, + Guid licenceAppId, + CancellationToken ct, + bool HasSwl90DayLicence = false, + Guid? companionAppId = null, + ApplicationOriginTypeCode? companionAppOrigin = null) { //if payment price is 0, directly set to Submitted, or PaymentPending var price = await _feeRepository.QueryAsync(new LicenceFeeQry() @@ -66,7 +72,8 @@ protected async Task CommitApplicationAsync(LicenceAppBase licAppBase, //companionAppId is the swl for sole proprietor which the business would pay for it, therefore the licence fee should be null here. if (companionAppId != null) { - await MoveFilesAsync((Guid)companionAppId, ct); + if (companionAppOrigin == ApplicationOriginTypeCode.Portal) //only authenticated swl save file in transient storage + await MoveFilesAsync((Guid)companionAppId, ct); await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, null, ct); } // Commit the main licence application