File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
ECER.Managers.Registry.Contract/ICRA Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ public record ICRAEligibilitiesQuery : IRequest<ICRAEligibilitiesQueryResults>
1313}
1414
1515public record ICRAEligibilitiesQueryResults ( IEnumerable < ICRAEligibility > Items ) ;
16-
1716public record ICRAEligibility ( )
1817{
1918 public string ? Id { get ; set ; }
Original file line number Diff line number Diff line change 11using AutoMapper ;
22using ECER . Infrastructure . Common ;
3+ using ECER . Managers . Registry . Contract . Applications ;
34using ECER . Managers . Registry . Contract . ICRA ;
5+ using ECER . Resources . Documents . Applications ;
46using ECER . Resources . Documents . ICRA ;
57using MediatR ;
68
@@ -20,7 +22,21 @@ public class ICRAEligibilityHandlers(
2022 public async Task < Contract . ICRA . ICRAEligibility ? > Handle ( SaveICRAEligibilityCommand request , CancellationToken cancellationToken )
2123 {
2224 ArgumentNullException . ThrowIfNull ( request ) ;
25+ if ( request . eligibility . Id == null )
26+ {
27+ var icraEligibilities = await iCRARepository . Query ( new ICRAQuery
28+ {
29+ ByApplicantId = request . eligibility . ApplicantId ,
30+ ByStatus = [ Resources . Documents . ICRA . ICRAStatus . Draft ]
31+ } , cancellationToken ) ;
2332
33+ var existingDraftICRA = icraEligibilities . FirstOrDefault ( ) ;
34+ if ( existingDraftICRA != null )
35+ {
36+ // user already has a draft icra eligibility
37+ throw new InvalidOperationException ( $ "User already has a draft ICRA with id '{ existingDraftICRA . Id } '") ;
38+ }
39+ }
2440 var iCRAEligibilityId = await iCRARepository . Save ( mapper . Map < Resources . Documents . ICRA . ICRAEligibility > ( request . eligibility ) ! , cancellationToken ) ;
2541
2642 var freshIcraEligibilities = await iCRARepository . Query ( new ICRAQuery
You can’t perform that action at this time.
0 commit comments