file-scoped namespaces
This commit is contained in:
		| @@ -1,6 +1,5 @@ | ||||
| using ApplicationLayer.GeneralExceptions; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Exceptions | ||||
| { | ||||
|     public class ApplicationAlreadyProcessedException() : ApiException("This application already processed or closed by applicant."); | ||||
| } | ||||
| namespace ApplicationLayer.Services.VisaApplications.Exceptions; | ||||
|  | ||||
| public class ApplicationAlreadyProcessedException() : ApiException("This application already processed or closed by applicant."); | ||||
| @@ -1,8 +1,7 @@ | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| public enum AuthorityRequestStatuses | ||||
| { | ||||
|     public enum AuthorityRequestStatuses | ||||
|     { | ||||
|         Approved, | ||||
|         Rejected | ||||
|     } | ||||
| } | ||||
|     Approved, | ||||
|     Rejected | ||||
| } | ||||
| @@ -1,44 +1,43 @@ | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of <see cref="VisaApplication"/> | ||||
| public class VisaApplicationModelForApplicant | ||||
| { | ||||
|     /// Model of <see cref="VisaApplication"/> | ||||
|     public class VisaApplicationModelForApplicant | ||||
|     { | ||||
|         /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|         public Guid Id { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|     public Guid Id { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|         public ApplicationStatus Status { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|     public ApplicationStatus Status { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|         public ReentryPermit? ReentryPermit { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|     public ReentryPermit? ReentryPermit { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|         public string DestinationCountry { get; set; } = null!; | ||||
|     /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|     public string DestinationCountry { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PastVisas"/> | ||||
|         public List<PastVisa> PastVisas { get; set; } = null!; | ||||
|     /// <inheritdoc cref="VisaApplication.PastVisas"/> | ||||
|     public List<PastVisa> PastVisas { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|         public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|     public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PastVisits"/> | ||||
|         public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|     /// <inheritdoc cref="VisaApplication.PastVisits"/> | ||||
|     public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|         public VisaCategory VisaCategory { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|     public VisaCategory VisaCategory { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|         public bool ForGroup { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|     public bool ForGroup { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|         public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|     public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|         public DateTime RequestDate { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|     public DateTime RequestDate { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|         public int ValidDaysRequested { get; set; } | ||||
|     } | ||||
| } | ||||
|     /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|     public int ValidDaysRequested { get; set; } | ||||
| } | ||||
| @@ -1,47 +1,46 @@ | ||||
| using ApplicationLayer.Services.Applicants.Models; | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of <see cref="VisaApplication"/> with applicant property | ||||
| public class VisaApplicationModelForAuthority | ||||
| { | ||||
|     /// Model of <see cref="VisaApplication"/> with applicant property | ||||
|     public class VisaApplicationModelForAuthority | ||||
|     { | ||||
|         /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|         public Guid Id { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|     public Guid Id { get; set; } | ||||
|  | ||||
|         /// Applicant of application | ||||
|         public ApplicantModel Applicant { get; set; } = null!; | ||||
|     /// Applicant of application | ||||
|     public ApplicantModel Applicant { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|         public ApplicationStatus Status { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|     public ApplicationStatus Status { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|         public ReentryPermit? ReentryPermit { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|     public ReentryPermit? ReentryPermit { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|         public string DestinationCountry { get; set; } = null!; | ||||
|     /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|     public string DestinationCountry { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PastVisas"/> | ||||
|         public List<PastVisa> PastVisas { get; set; } = null!; | ||||
|     /// <inheritdoc cref="VisaApplication.PastVisas"/> | ||||
|     public List<PastVisa> PastVisas { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|         public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|     public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|         public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|     public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|         public VisaCategory VisaCategory { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|     public VisaCategory VisaCategory { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|         public bool ForGroup { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|     public bool ForGroup { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|         public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|     public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|         public DateTime RequestDate { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|     public DateTime RequestDate { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|         public int ValidDaysRequested { get; set; } | ||||
|     } | ||||
| } | ||||
|     /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|     public int ValidDaysRequested { get; set; } | ||||
| } | ||||
| @@ -2,12 +2,12 @@ | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class PastVisaValidator : AbstractValidator<PastVisa> | ||||
| { | ||||
|     public class PastVisaValidator : AbstractValidator<PastVisa> | ||||
|     public PastVisaValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public PastVisaValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(v => v.ExpirationDate) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Expiration date of past visa can not be empty") | ||||
| @@ -24,5 +24,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Name of past visa can not be empty"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -3,12 +3,12 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class PastVisitValidator : AbstractValidator<PastVisit> | ||||
| { | ||||
|     public class PastVisitValidator : AbstractValidator<PastVisit> | ||||
|     public PastVisitValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public PastVisitValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(v => v.StartDate) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Start date of past visit can not be empty") | ||||
| @@ -27,5 +27,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .MaximumLength(ConfigurationConstraints.CountryNameLength) | ||||
|                 .WithMessage($"Destination Country of past visit length must be less than {ConfigurationConstraints.CountryNameLength}"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -3,12 +3,12 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class PermissionToDestCountryValidator : AbstractValidator<PermissionToDestCountry?> | ||||
| { | ||||
|     public class PermissionToDestCountryValidator : AbstractValidator<PermissionToDestCountry?> | ||||
|     public PermissionToDestCountryValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public PermissionToDestCountryValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(p => p!.ExpirationDate) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Expiration date of permission to destination Country can not be empty") | ||||
| @@ -21,5 +21,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .MaximumLength(ConfigurationConstraints.IssuerNameLength) | ||||
|                 .WithMessage($"Issuer of permission to destination Country length must be less than {ConfigurationConstraints.IssuerNameLength}"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -3,12 +3,12 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class ReentryPermitValidator : AbstractValidator<ReentryPermit?> | ||||
| { | ||||
|     public class ReentryPermitValidator : AbstractValidator<ReentryPermit?> | ||||
|     public ReentryPermitValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public ReentryPermitValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(p => p!.Number) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Re-entry permit number can not be empty") | ||||
| @@ -21,5 +21,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .GreaterThan(dateTimeProvider.Now()) | ||||
|                 .WithMessage("Re-entry permit must not be expired"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -4,51 +4,50 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class VisaApplicationCreateRequestValidator : AbstractValidator<VisaApplicationCreateRequest> | ||||
| { | ||||
|     public class VisaApplicationCreateRequestValidator : AbstractValidator<VisaApplicationCreateRequest> | ||||
|     public VisaApplicationCreateRequestValidator( | ||||
|         IValidator<ReentryPermit?> reentryPermitValidator, | ||||
|         IValidator<PastVisa> pastVisaValidator, | ||||
|         IValidator<PermissionToDestCountry?> permissionToDestCountryValidator, | ||||
|         IValidator<PastVisit> pastVisitValidator, | ||||
|         IApplicantsRepository applicants, | ||||
|         IUserIdProvider userIdProvider) | ||||
|     { | ||||
|         public VisaApplicationCreateRequestValidator( | ||||
|             IValidator<ReentryPermit?> reentryPermitValidator, | ||||
|             IValidator<PastVisa> pastVisaValidator, | ||||
|             IValidator<PermissionToDestCountry?> permissionToDestCountryValidator, | ||||
|             IValidator<PastVisit> pastVisitValidator, | ||||
|             IApplicantsRepository applicants, | ||||
|             IUserIdProvider userIdProvider) | ||||
|         { | ||||
|             RuleFor(r => r.ReentryPermit) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Non-residents must provide re-entry permission") | ||||
|                 .SetValidator(reentryPermitValidator) | ||||
|                 .WhenAsync(async (r, ct) => | ||||
|                     await applicants.IsApplicantNonResidentByUserId(userIdProvider.GetUserId(), ct)); | ||||
|         RuleFor(r => r.ReentryPermit) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Non-residents must provide re-entry permission") | ||||
|             .SetValidator(reentryPermitValidator) | ||||
|             .WhenAsync(async (r, ct) => | ||||
|                 await applicants.IsApplicantNonResidentByUserId(userIdProvider.GetUserId(), ct)); | ||||
|  | ||||
|             RuleFor(r => r.DestinationCountry) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Destination country can not be empty"); | ||||
|         RuleFor(r => r.DestinationCountry) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Destination country can not be empty"); | ||||
|  | ||||
|             RuleFor(r => r.VisaCategory) | ||||
|                 .IsInEnum(); | ||||
|         RuleFor(r => r.VisaCategory) | ||||
|             .IsInEnum(); | ||||
|  | ||||
|             RuleFor(r => r.RequestedNumberOfEntries) | ||||
|                 .IsInEnum(); | ||||
|         RuleFor(r => r.RequestedNumberOfEntries) | ||||
|             .IsInEnum(); | ||||
|  | ||||
|             RuleFor(r => r.ValidDaysRequested) | ||||
|                 .GreaterThan(0) | ||||
|                 .WithMessage($"Valid days requested should be positive number and less than {ConfigurationConstraints.MaxValidDays}") | ||||
|                 .LessThanOrEqualTo(ConfigurationConstraints.MaxValidDays) | ||||
|                 .WithMessage($"Valid days requested must be less than or equal to {ConfigurationConstraints.MaxValidDays}"); | ||||
|         RuleFor(r => r.ValidDaysRequested) | ||||
|             .GreaterThan(0) | ||||
|             .WithMessage($"Valid days requested should be positive number and less than {ConfigurationConstraints.MaxValidDays}") | ||||
|             .LessThanOrEqualTo(ConfigurationConstraints.MaxValidDays) | ||||
|             .WithMessage($"Valid days requested must be less than or equal to {ConfigurationConstraints.MaxValidDays}"); | ||||
|  | ||||
|             RuleForEach(r => r.PastVisas) | ||||
|                 .SetValidator(pastVisaValidator); | ||||
|         RuleForEach(r => r.PastVisas) | ||||
|             .SetValidator(pastVisaValidator); | ||||
|  | ||||
|             When(r => r.VisaCategory == VisaCategory.Transit, | ||||
|                 () => | ||||
|                     RuleFor(r => r.PermissionToDestCountry) | ||||
|                         .SetValidator(permissionToDestCountryValidator)); | ||||
|         When(r => r.VisaCategory == VisaCategory.Transit, | ||||
|             () => | ||||
|                 RuleFor(r => r.PermissionToDestCountry) | ||||
|                     .SetValidator(permissionToDestCountryValidator)); | ||||
|  | ||||
|             RuleForEach(r => r.PastVisits) | ||||
|                 .SetValidator(pastVisitValidator); | ||||
|         } | ||||
|         RuleForEach(r => r.PastVisits) | ||||
|             .SetValidator(pastVisitValidator); | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user