Skip to content

Commit 65d39f1

Browse files
committed
ECER-4776: Sonar Qube ICRA eligibility object problems resolved
1 parent 5a527ac commit 65d39f1

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/ECER.Managers.Registry/ICRAEligibilityHandlers.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,11 @@ public class ICRAEligibilityHandlers(
2121
{
2222
ArgumentNullException.ThrowIfNull(request);
2323

24-
if (request.eligibility.Id == null)
25-
{
26-
27-
var iCRAEligibilities = await iCRARepository.Query(new ICRAQuery
28-
{
29-
ByApplicantId = request.eligibility.ApplicantId,
30-
}, cancellationToken);
31-
32-
var ICRAEligibilityResults = new ICRAEligibilitiesQueryResults(mapper.Map<IEnumerable<Contract.ICRA.ICRAEligibility>>(iCRAEligibilities)!);
33-
34-
}
35-
var ICRAEligibilityId = await iCRARepository.Save(mapper.Map<Resources.Documents.ICRA.ICRAEligibility>(request.eligibility)!, cancellationToken);
24+
var iCRAEligibilityId = await iCRARepository.Save(mapper.Map<Resources.Documents.ICRA.ICRAEligibility>(request.eligibility)!, cancellationToken);
3625

3726
var freshIcraEligibilities = await iCRARepository.Query(new ICRAQuery
3827
{
39-
ById = ICRAEligibilityId,
28+
ById = iCRAEligibilityId,
4029
}, cancellationToken);
4130

4231
return mapper.Map<Contract.ICRA.ICRAEligibility>(freshIcraEligibilities.SingleOrDefault())!;

src/ECER.Resources.Documents/ICRA/ICRARepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public async Task<IEnumerable<ICRAEligibility>> Query(ICRAQuery query, Cancellat
4545
return mapper.Map<IEnumerable<ICRAEligibility>>(results)!.ToList();
4646
}
4747

48-
public async Task<string> Save(ICRAEligibility eligibility, CancellationToken cancellationToken)
48+
public async Task<string> Save(ICRAEligibility iCRAEligibility, CancellationToken cancellationToken)
4949
{
5050
await Task.CompletedTask;
5151

52-
var applicant = context.ContactSet.SingleOrDefault(c => c.ContactId == Guid.Parse(eligibility.ApplicantId));
53-
if (applicant == null) throw new InvalidOperationException($"Applicant '{eligibility.ApplicantId}' not found");
52+
var applicant = context.ContactSet.SingleOrDefault(c => c.ContactId == Guid.Parse(iCRAEligibility.ApplicantId));
53+
if (applicant == null) throw new InvalidOperationException($"Applicant '{iCRAEligibility.ApplicantId}' not found");
5454

55-
var icraEligibility = mapper.Map<ecer_ICRAEligibilityAssessment>(eligibility)!;
55+
var icraEligibility = mapper.Map<ecer_ICRAEligibilityAssessment>(iCRAEligibility)!;
5656
if (!icraEligibility.ecer_ICRAEligibilityAssessmentId.HasValue)
5757
{
5858
icraEligibility.ecer_ICRAEligibilityAssessmentId = Guid.NewGuid();

0 commit comments

Comments
 (0)