@@ -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
151176public enum ICRAStatus
@@ -163,3 +188,15 @@ public enum ICRAStatus
163188
164189public record ICRAEligibilitySubmissionRequest ( string Id ) ;
165190public 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+ }
0 commit comments