Skip to content

Commit bb5543d

Browse files
Merge tag 'release-1.1.3' into develop
2 parents 52e0c45 + 62e65ec commit bb5543d

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/Spd.Resource.Repository/Application/ApplicationRepository.Application.cs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,39 @@ public async Task ProcessAppWithSharableClearanceAsync(ApplicationCreateCmd crea
138138
if (!createApplicationCmd.SharedClearanceId.HasValue)
139139
throw new ArgumentException("SharedClearanceId cannot be null");
140140
account? org = await _context.GetOrgById(createApplicationCmd.OrgId, ct);
141-
spd_clearance? clearance = await _context.GetClearanceById((Guid)createApplicationCmd.SharedClearanceId, ct);
142141
contact? contact = await _context.contacts.Where(c => c.contactid == createApplicationCmd.ContactId).FirstOrDefaultAsync(ct);
143142
_mapper.Map<ApplicationCreateCmd, contact>(createApplicationCmd, contact);
144143
_context.UpdateObject(contact);
145144

146-
Guid teamGuid = Guid.Parse(DynamicsConstants.Screening_Risk_Assessment_Coordinator_Team_Guid);
147-
team? team = await _context.teams.Where(t => t.teamid == teamGuid).FirstOrDefaultAsync(ct);
145+
//spdbt-3220
146+
spd_clearance? clearance = await _context.spd_clearances
147+
.Expand(c => c.spd_CaseID)
148+
.Where(c => c.spd_clearanceid == (Guid)createApplicationCmd.SharedClearanceId)
149+
.FirstOrDefaultAsync(ct);
150+
if (clearance == null)
151+
throw new ApiException(HttpStatusCode.BadRequest, "Cannot find specified clearance.");
152+
team? team = null;
153+
int state;
154+
int status;
155+
if (clearance.spd_CaseID.spd_risklevel == (int)CaseRiskLevelOptionSet.L2 || clearance.spd_CaseID.spd_risklevel == (int)CaseRiskLevelOptionSet.L3)
156+
{
157+
Guid teamGuid = Guid.Parse(DynamicsConstants.Screening_Risk_Assessment_Coordinator_Team_Guid);
158+
team = await _context.teams.Where(t => t.teamid == teamGuid).FirstOrDefaultAsync(ct);
159+
status = (int)ClearanceAccessStatusOptionSet.Draft;
160+
state = DynamicsConstants.StateCode_Active;
161+
}
162+
else
163+
{
164+
Guid teamGuid = Guid.Parse(DynamicsConstants.Client_Service_Team_Guid);
165+
team = await _context.teams.Where(t => t.teamid == teamGuid).FirstOrDefaultAsync(ct);
166+
status = (int)ClearanceAccessStatusOptionSet.Approved;
167+
state = DynamicsConstants.StateCode_Active;
168+
}
169+
148170
spd_clearanceaccess clearanceaccess = new() { spd_clearanceaccessid = Guid.NewGuid() };
149-
clearanceaccess.statecode = DynamicsConstants.StateCode_Active;
150-
clearanceaccess.statuscode = (int)ClearanceAccessStatusOptionSet.Draft;
171+
clearanceaccess.statecode = state;
172+
clearanceaccess.statuscode = status;
173+
clearanceaccess.spd_issystemgenerated = true;
151174
_context.AddTospd_clearanceaccesses(clearanceaccess);
152175
_context.SetLink(clearanceaccess, nameof(clearanceaccess.spd_OrganizationId), org);
153176
_context.SetLink(clearanceaccess, nameof(clearanceaccess.spd_ClearanceId), clearance);

src/Spd.Utilities.Dynamics/OptionSets.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,11 @@ public enum EventStatusReasonOptionSet
410410
Success = 100000002, //Inactive State status reason
411411
Fail = 100000003 //Inactive State status reason
412412
}
413+
414+
public enum CaseRiskLevelOptionSet
415+
{
416+
L1 = 100000000,
417+
L2 = 100000001,
418+
L3 = 100000002
419+
}
413420
}

0 commit comments

Comments
 (0)