Fixed errors and wrong model
This commit is contained in:
		| @@ -53,6 +53,10 @@ public class VisaApplicationRequestsHandler( | ||||
|     { | ||||
|         var applicantId = await applicants.GetApplicantIdByUserId(userIdProvider.GetUserId(), cancellationToken); | ||||
|         var application = await applications.GetByApplicantAndApplicationIdAsync(applicantId, applicationId, cancellationToken); | ||||
|         if (application.Status is ApplicationStatus.Approved or ApplicationStatus.Rejected) | ||||
|         { | ||||
|             throw new ApplicationAlreadyProcessedException(); | ||||
|         } | ||||
|  | ||||
|         application.Status = ApplicationStatus.Closed; | ||||
|         await applications.UpdateAsync(application, cancellationToken); | ||||
| @@ -95,4 +99,4 @@ public class VisaApplicationRequestsHandler( | ||||
|  | ||||
|         return model; | ||||
|     } | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -17,6 +17,12 @@ public class VisaApplicationCreateRequestValidator : AbstractValidator<VisaAppli | ||||
|         IApplicantsRepository applicants, | ||||
|         IUserIdProvider userIdProvider) | ||||
|     { | ||||
|         RuleFor(r => r.PermissionToDestCountry) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("For transit you must provide permission to destination country") | ||||
|             .SetValidator(permissionToDestCountryModelValidator) | ||||
|             .When(r => r.VisaCategory is VisaCategory.Transit); | ||||
|  | ||||
|         RuleFor(r => r.ReentryPermit) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Non-residents must provide re-entry permission") | ||||
| @@ -43,11 +49,6 @@ public class VisaApplicationCreateRequestValidator : AbstractValidator<VisaAppli | ||||
|         RuleForEach(r => r.PastVisas) | ||||
|             .SetValidator(pastVisaModelValidator); | ||||
|  | ||||
|         When(r => r.VisaCategory == VisaCategory.Transit, | ||||
|             () => | ||||
|                 RuleFor(r => r.PermissionToDestCountry) | ||||
|                     .SetValidator(permissionToDestCountryModelValidator)); | ||||
|  | ||||
|         RuleForEach(r => r.PastVisits) | ||||
|             .SetValidator(pastVisitModelValidator); | ||||
|     } | ||||
|   | ||||
| @@ -8,8 +8,6 @@ namespace ApplicationLayer.Services.VisaApplications.Requests; | ||||
| /// Model of visa request from user | ||||
| public class VisaApplicationCreateRequest | ||||
| { | ||||
|  | ||||
|     [Required] | ||||
|     public ReentryPermitModel? ReentryPermit { get; set; } | ||||
|  | ||||
|     [Required] | ||||
| @@ -32,8 +30,6 @@ public class VisaApplicationCreateRequest | ||||
|     [Required] | ||||
|     public PastVisaModel[] PastVisas { get; set; } = null!; | ||||
|  | ||||
|     //todo remove attribute | ||||
|     [Required] | ||||
|     public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|     [Required] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user