Skip to content

Commit

Permalink
[SPDBT-3470] Applicant SWL Number not set (#2062)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- [SPDBT-3470] Applicant SWL Number not set
  • Loading branch information
peggy-quartech authored Jan 7, 2025
1 parent 1738a99 commit b8816c3
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task<BizLicApplicationCmdResp> 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);

Expand Down Expand Up @@ -114,16 +115,7 @@ public async Task<BizLicApplicationCmdResp> 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);

Expand Down Expand Up @@ -287,6 +279,20 @@ private async Task<spd_businesscontact> 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);
Expand Down

0 comments on commit b8816c3

Please sign in to comment.