Skip to content

Commit 63a0e0d

Browse files
committed
ECER-5118: ICRA eligibility object status and manage page api endpoint
1 parent dcaa597 commit 63a0e0d

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/ECER.Clients.RegistryPortal/ECER.Clients.RegistryPortal.Server/ICRA/ICRAEligibilitiesEndpoints.cs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,32 @@ public void Register(IEndpointRouteBuilder endpointRouteBuilder)
8989
.WithOpenApi("Submit an ICRA Eligibility", string.Empty, "icra_post")
9090
.RequireAuthorization()
9191
.WithParameterValidation();
92+
93+
endpointRouteBuilder.MapGet("/api/icra/{id}/status", async Task<Results<Ok<ICRAEligibilityStatus>, BadRequest<ProblemDetails>, NotFound<ProblemDetails>>> (string id, HttpContext ctx, IMediator messageBus, IMapper mapper, CancellationToken ct) =>
94+
{
95+
var userId = ctx.User.GetUserContext()?.UserId;
96+
bool IdIsNotGuid = !Guid.TryParse(id, out _);
97+
if (IdIsNotGuid)
98+
{
99+
return TypedResults.BadRequest(new ProblemDetails() { Title = "ICRAEligibilityId is not valid" });
100+
}
101+
102+
var query = new ICRAEligibilitiesQuery
103+
{
104+
ById = id,
105+
ByApplicantId = userId
106+
};
107+
var result = await messageBus.Send(query, ct);
108+
var eligibility = result.Items.FirstOrDefault();
109+
if (eligibility == null)
110+
{
111+
return TypedResults.NotFound(new ProblemDetails() { Title = "ICRA eligibility not found" });
112+
}
113+
return TypedResults.Ok(mapper.Map<ICRAEligibilityStatus>(eligibility));
114+
})
115+
.WithOpenApi("Handles icra eligibility status queries", string.Empty, "icra_status_get")
116+
.RequireAuthorization()
117+
.WithParameterValidation();
92118
}
93119
}
94120

@@ -103,10 +129,8 @@ public record ICRAEligibility()
103129
public string? Id { get; set; }
104130
public string ApplicantId { get; set; } = string.Empty;
105131
public string? PortalStage { get; set; }
106-
107132
public DateTime? SignedDate { get; set; }
108133
public DateTime? CreatedOn { get; set; }
109-
110134
public ICRAStatus Status { get; set; }
111135
public IEnumerable<InternationalCertification> InternationalCertifications { get; set; } = Array.Empty<InternationalCertification>();
112136
public IEnumerable<EmploymentReference> EmploymentReferences { get; set; } = Array.Empty<EmploymentReference>();
@@ -146,6 +170,7 @@ public record EmploymentReference
146170
public string? FirstName { get; set; }
147171
public string? EmailAddress { get; set; }
148172
public string? PhoneNumber { get; set; }
173+
public ICRAStatus? Status { get; set; }
149174
}
150175

151176
public enum ICRAStatus
@@ -163,3 +188,15 @@ public enum ICRAStatus
163188

164189
public record ICRAEligibilitySubmissionRequest(string Id);
165190
public record SubmitICRAEligibilityResponse(ICRAEligibility Eligibility);
191+
192+
public record ICRAEligibilityStatus(string Id, DateTime? CreatedOn, DateTime? SignedDate, ICRAStatus Status)
193+
{
194+
public IEnumerable<InternationalCertification> InternationalCertifications { get; set; } = Array.Empty<InternationalCertification>();
195+
public IEnumerable<EmploymentReferenceStatus> EmploymentReferencesStatus { get; set; } = Array.Empty<EmploymentReferenceStatus>();
196+
}
197+
198+
public record EmploymentReferenceStatus(string Id, Managers.Registry.Contract.Applications.WorkExperienceRefStage? Status, string? FirstName, string? LastName, string? EmailAddress)
199+
{
200+
public string? PhoneNumber { get; set; }
201+
public bool? WillProvideReference { get; set; }
202+
}

src/ECER.Clients.RegistryPortal/ECER.Clients.RegistryPortal.Server/ICRA/ICRAEligibilityMapper.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ public ICRAEligibilityMapper()
1212

1313
CreateMap<InternationalCertification, Managers.Registry.Contract.ICRA.InternationalCertification>()
1414
.ReverseMap();
15-
CreateMap<EmploymentReference, Managers.Registry.Contract.ICRA.EmploymentReference>().ReverseMap();
15+
CreateMap<EmploymentReference, Managers.Registry.Contract.ICRA.EmploymentReference>()
16+
.ForMember(d => d.Status, o => o.Ignore())
17+
.ForMember(d => d.WillProvideReference, o => o.Ignore())
18+
.ReverseMap();
19+
CreateMap<Managers.Registry.Contract.ICRA.ICRAEligibility, ICRAEligibilityStatus>()
20+
.ForMember(d => d.EmploymentReferencesStatus, o => o.MapFrom(s => s.EmploymentReferences));
21+
CreateMap<Managers.Registry.Contract.ICRA.EmploymentReference, EmploymentReferenceStatus>()
22+
.ForCtorParam(nameof(EmploymentReference.Id), o => o.MapFrom(s => s.Id))
23+
.ForCtorParam(nameof(EmploymentReference.Status), o => o.MapFrom(s => s.Status))
24+
.ForCtorParam(nameof(EmploymentReference.FirstName), o => o.MapFrom(s => s.FirstName))
25+
.ForCtorParam(nameof(EmploymentReference.LastName), o => o.MapFrom(s => s.LastName))
26+
.ForCtorParam(nameof(EmploymentReference.EmailAddress), o => o.MapFrom(s => s.EmailAddress))
27+
.ForMember(d => d.PhoneNumber, o => o.MapFrom(s => s.PhoneNumber))
28+
.ForMember(d => d.WillProvideReference, o => o.MapFrom(s => s.WillProvideReference));
1629
}
1730
}

0 commit comments

Comments
 (0)