diff --git a/.github/workflows/zap-scans.yml b/.github/workflows/zap-scans.yml index 2975b2981..4e77cd1d3 100644 --- a/.github/workflows/zap-scans.yml +++ b/.github/workflows/zap-scans.yml @@ -47,6 +47,6 @@ jobs: uses: zaproxy/action-api-scan@v0.9.0 with: token: ${{ secrets.GITHUB_TOKEN }} - target: "https://justice.gov.bc.ca/train-security/swagger/v1/swagger.json" + target: "https://justice.gov.bc.ca/licensing/swagger/v1/swagger.json" artifact_name: "licensing_portal_api_zap_scan" issue_title: "licensing_portal_api_zap_scan" diff --git a/src/Spd.Resource.Repository/BizLicApplication/BizLicApplicationRepository.cs b/src/Spd.Resource.Repository/BizLicApplication/BizLicApplicationRepository.cs index 37c81c840..1dbb6039a 100644 --- a/src/Spd.Resource.Repository/BizLicApplication/BizLicApplicationRepository.cs +++ b/src/Spd.Resource.Repository/BizLicApplication/BizLicApplicationRepository.cs @@ -62,6 +62,7 @@ public async Task CreateBizLicApplicationAsync(CreateB await SetInfoFromBiz(biz, app, cmd.ApplicantIsBizManager ?? false, ct); await SetOwner(app, Guid.Parse(DynamicsConstants.Licensing_Client_Service_Team_Guid), ct); + await SetApplicantSwlLicenceId(app, cmd.ApplicantSwlLicenceId, ct); SharedRepositoryFuncs.LinkServiceType(_context, cmd.ServiceTypeCode, app); SharedRepositoryFuncs.LinkSubmittedByPortalUser(_context, cmd.SubmittedByPortalUserId, app); @@ -114,16 +115,7 @@ public async Task SaveBizLicApplicationAsync(SaveBizLi else _context.SetLink(app, nameof(app.spd_CurrentExpiredLicenceId), null); - if (cmd.ApplicantSwlLicenceId != null) - { - var licence = _context.spd_licences.Where(l => l.spd_licenceid == cmd.ApplicantSwlLicenceId).FirstOrDefault(); - if (licence != null) - { - _context.SetLink(app, nameof(spd_application.spd_ApplicantSWLNumberId), licence); - } - } - else - _context.SetLink(app, nameof(app.spd_ApplicantSWLNumberId), null); + await SetApplicantSwlLicenceId(app, cmd.ApplicantSwlLicenceId, ct); SharedRepositoryFuncs.LinkSubmittedByPortalUser(_context, cmd.SubmittedByPortalUserId, app); @@ -187,6 +179,7 @@ public async Task GetBizLicApplicationAsync(Guid licenceA .Expand(b => b.spd_ContactId) .Where(b => b.spd_position_spd_businesscontact.Any(p => p.spd_positionid == position.spd_positionid)) .Where(b => b.spd_businesscontact_spd_application.Any(b => b.spd_applicationid == app.spd_applicationid)) + .Where(b => b.statecode != DynamicsConstants.StateCode_Inactive) .FirstOrDefault(); PrivateInvestigatorSwlContactInfo privateInvestigatorInfo = new() @@ -286,6 +279,20 @@ private async Task UpsertPrivateInvestigator(PrivateInvesti return bizContact; } + private async Task SetApplicantSwlLicenceId(spd_application app, Guid? applicantSwlLicenceId, CancellationToken ct) + { + if (applicantSwlLicenceId != null) + { + var licence = await _context.spd_licences.Where(l => l.spd_licenceid == applicantSwlLicenceId).FirstOrDefaultAsync(ct); + if (licence != null) + { + _context.SetLink(app, nameof(spd_application.spd_ApplicantSWLNumberId), licence); + } + } + else + _context.SetLink(app, nameof(app.spd_ApplicantSWLNumberId), null); + } + private void AddPrivateInvestigatorLink(spd_businesscontact bizContact, spd_application app) { _context.AddLink(bizContact, nameof(spd_application.spd_businesscontact_spd_application), app); @@ -388,6 +395,7 @@ private async Task SetInfoFromBiz(account biz, spd_application app, bool applica _context.SetLink(app, nameof(spd_application.spd_ApplicantId_account), biz); _context.SetLink(app, nameof(spd_application.spd_OrganizationId), biz); + await _context.SaveChangesAsync(ct); } private async Task SetOwner(spd_application app, Guid ownerId, CancellationToken ct)