Added models for presentation layer with data annotations
This commit is contained in:
		| @@ -0,0 +1,21 @@ | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using Domains; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of past visa for presentation layer | ||||
| public class PastVisaModel | ||||
| { | ||||
|     // Date of issue | ||||
|     [Required] | ||||
|     public DateTime IssueDate { get; set; } | ||||
|  | ||||
|     /// Name of visa | ||||
|     [Required] | ||||
|     [MaxLength(ConfigurationConstraints.VisaNameLength)] | ||||
|     public string Name { get; set; } = null!; | ||||
|  | ||||
|     /// Date when visa expires | ||||
|     [Required] | ||||
|     public DateTime ExpirationDate { get; set; } | ||||
| } | ||||
| @@ -0,0 +1,21 @@ | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using Domains; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of past visit for presentation layer | ||||
| public class PastVisitModel | ||||
| { | ||||
|     /// First day of past visit | ||||
|     [Required] | ||||
|     public DateTime StartDate { get; set; } | ||||
|  | ||||
|     /// Last day of past visit | ||||
|     [Required] | ||||
|     public DateTime EndDate { get; set; } | ||||
|  | ||||
|     /// Destination country of past visit | ||||
|     [Required] | ||||
|     [MaxLength(ConfigurationConstraints.CountryNameLength)] | ||||
|     public string DestinationCountry { get; set; } = null!; | ||||
| } | ||||
| @@ -0,0 +1,17 @@ | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using Domains; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of permission to destination country for presentation layer | ||||
| public class PermissionToDestCountryModel | ||||
| { | ||||
|     /// Date when permission to destination country expires | ||||
|     [Required] | ||||
|     public DateTime ExpirationDate { get; set; } | ||||
|  | ||||
|     /// Issuing authority | ||||
|     [Required] | ||||
|     [MaxLength(ConfigurationConstraints.IssuerNameLength)] | ||||
|     public string Issuer { get; set; } = null!; | ||||
| } | ||||
| @@ -0,0 +1,17 @@ | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using Domains; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of re-entry permit for presentation layer | ||||
| public class ReentryPermitModel | ||||
| { | ||||
|     /// Number of re-entry permit | ||||
|     [Required] | ||||
|     [MaxLength(ConfigurationConstraints.ReentryPermitNumberLength)] | ||||
|     public string Number { get; set; } = null!; | ||||
|  | ||||
|     /// Date when re-entry permit expires | ||||
|     [Required] | ||||
|     public DateTime ExpirationDate { get; set; } | ||||
| } | ||||
| @@ -0,0 +1,26 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models.Validation; | ||||
|  | ||||
| public class PastVisaModelValidator : AbstractValidator<PastVisaModel> | ||||
| { | ||||
|     public PastVisaModelValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         RuleFor(v => v.ExpirationDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Expiration date of past visa can not be empty") | ||||
|             .GreaterThan(v => v.IssueDate) | ||||
|             .WithMessage("Past visa expiration date can not be earlier than issue date"); | ||||
|  | ||||
|         RuleFor(v => v.IssueDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Issue date of past visa can not be empty") | ||||
|             .LessThan(dateTimeProvider.Now()) | ||||
|             .WithMessage("Issue date of past visa must be in past"); | ||||
|  | ||||
|         RuleFor(v => v.Name) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Name of past visa can not be empty"); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,29 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using Domains; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models.Validation; | ||||
|  | ||||
| public class PastVisitModelValidator : AbstractValidator<PastVisitModel> | ||||
| { | ||||
|     public PastVisitModelValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         RuleFor(v => v.StartDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Start date of past visit can not be empty") | ||||
|             .LessThan(v => v.EndDate) | ||||
|             .WithMessage("Start date of past visit must be earlier than end date") | ||||
|             .LessThan(dateTimeProvider.Now()) | ||||
|             .WithMessage("Start date of past visit must be in past"); | ||||
|  | ||||
|         RuleFor(v => v.EndDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("End date of past visit can not be empty"); | ||||
|  | ||||
|         RuleFor(v => v.DestinationCountry) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Destination Country of past visit can not be null") | ||||
|             .MaximumLength(ConfigurationConstraints.CountryNameLength) | ||||
|             .WithMessage($"Destination Country of past visit length must be less than {ConfigurationConstraints.CountryNameLength}"); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,23 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using Domains; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models.Validation; | ||||
|  | ||||
| public class PermissionToDestCountryModelValidator : AbstractValidator<PermissionToDestCountryModel?> | ||||
| { | ||||
|     public PermissionToDestCountryModelValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         RuleFor(p => p!.ExpirationDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Expiration date of permission to destination Country can not be empty") | ||||
|             .GreaterThan(dateTimeProvider.Now()) | ||||
|             .WithMessage("Permission to destination Country must not be expired"); | ||||
|  | ||||
|         RuleFor(p => p!.Issuer) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Issuer of permission for destination Country can not be empty") | ||||
|             .MaximumLength(ConfigurationConstraints.IssuerNameLength) | ||||
|             .WithMessage($"Issuer of permission to destination Country length must be less than {ConfigurationConstraints.IssuerNameLength}"); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,23 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using Domains; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models.Validation; | ||||
|  | ||||
| public class ReentryPermitModelValidator : AbstractValidator<ReentryPermitModel?> | ||||
| { | ||||
|     public ReentryPermitModelValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         RuleFor(p => p!.Number) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Re-entry permit number can not be empty") | ||||
|             .MaximumLength(ConfigurationConstraints.ReentryPermitNumberLength) | ||||
|             .WithMessage($"Re-entry permit number length must be less than {ConfigurationConstraints.ReentryPermitNumberLength}"); | ||||
|  | ||||
|         RuleFor(p => p!.ExpirationDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Re-entry permit expiration date can not be empty") | ||||
|             .GreaterThan(dateTimeProvider.Now()) | ||||
|             .WithMessage("Re-entry permit must not be expired"); | ||||
|     } | ||||
| } | ||||
| @@ -2,42 +2,42 @@ | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of <see cref="VisaApplication"/> | ||||
| /// Model of <see cref="VisaApplication" /> | ||||
| public class VisaApplicationModelForApplicant | ||||
| { | ||||
|     /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|     /// <inheritdoc cref="VisaApplication.Id" /> | ||||
|     public Guid Id { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|     /// <inheritdoc cref="VisaApplication.Status" /> | ||||
|     public ApplicationStatus Status { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|     public ReentryPermit? ReentryPermit { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.ReentryPermit" /> | ||||
|     public ReentryPermitModel? ReentryPermit { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|     /// <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<PastVisaModel> PastVisas { get; set; } = null!; | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|     public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.PermissionToDestCountry" /> | ||||
|     public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.PastVisits"/> | ||||
|     public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|     /// <inheritdoc cref="VisaApplication.PastVisits" /> | ||||
|     public List<PastVisitModel> PastVisits { get; set; } = null!; | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|     /// <inheritdoc cref="VisaApplication.VisaCategory" /> | ||||
|     public VisaCategory VisaCategory { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|     /// <inheritdoc cref="VisaApplication.ForGroup" /> | ||||
|     public bool ForGroup { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|     /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" /> | ||||
|     public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|     /// <inheritdoc cref="VisaApplication.RequestDate" /> | ||||
|     public DateTime RequestDate { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|     /// <inheritdoc cref="VisaApplication.ValidDaysRequested" /> | ||||
|     public int ValidDaysRequested { get; set; } | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -3,44 +3,44 @@ using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models; | ||||
|  | ||||
| /// Model of <see cref="VisaApplication"/> with applicant property | ||||
| /// Model of <see cref="VisaApplication" /> with applicant property | ||||
| public class VisaApplicationModelForAuthority | ||||
| { | ||||
|     /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|     /// <inheritdoc cref="VisaApplication.Id" /> | ||||
|     public Guid Id { get; set; } | ||||
|  | ||||
|     /// Applicant of application | ||||
|     public ApplicantModel Applicant { get; set; } = null!; | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|     /// <inheritdoc cref="VisaApplication.Status" /> | ||||
|     public ApplicationStatus Status { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|     public ReentryPermit? ReentryPermit { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.ReentryPermit" /> | ||||
|     public ReentryPermitModel? ReentryPermit { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|     /// <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<PastVisaModel> PastVisas { get; set; } = null!; | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|     public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|     /// <inheritdoc cref="VisaApplication.PermissionToDestCountry" /> | ||||
|     public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|     public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|     public List<PastVisitModel> PastVisits { get; set; } = null!; | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|     /// <inheritdoc cref="VisaApplication.VisaCategory" /> | ||||
|     public VisaCategory VisaCategory { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|     /// <inheritdoc cref="VisaApplication.ForGroup" /> | ||||
|     public bool ForGroup { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|     /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" /> | ||||
|     public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|     /// <inheritdoc cref="VisaApplication.RequestDate" /> | ||||
|     public DateTime RequestDate { get; set; } | ||||
|  | ||||
|     /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|     /// <inheritdoc cref="VisaApplication.ValidDaysRequested" /> | ||||
|     public int ValidDaysRequested { get; set; } | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user