Added status to application, response models of application for applicant and authority
This commit is contained in:
		| @@ -1,13 +0,0 @@ | ||||
| namespace ApplicationLayer.Services.Applicants.Models; | ||||
|  | ||||
| public class AddressModel | ||||
| { | ||||
|     /// City part of address | ||||
|     public Guid CityId { get; set; } | ||||
|  | ||||
|     /// Street part of address | ||||
|     public string Street { get; set; } = null!; | ||||
|  | ||||
|     /// Building part of address | ||||
|     public string Building { get; set; } = null!; | ||||
| } | ||||
| @@ -0,0 +1,50 @@ | ||||
| using Domains.ApplicantDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.Applicants.Models | ||||
| { | ||||
|     /// Model of <see cref="Applicant"/> | ||||
|     public class ApplicantModel | ||||
|     { | ||||
|         /// <inheritdoc cref="Applicant.Name"/> | ||||
|         public Name Name { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.Passport"/> | ||||
|         public Passport Passport { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.BirthDate"/> | ||||
|         public DateTime BirthDate { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.CountryOfBirth"/> | ||||
|         public string CountryOfBirth { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.CityOfBirth"/> | ||||
|         public string CityOfBirth { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.Citizenship"/> | ||||
|         public string Citizenship { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.CitizenshipByBirth"/> | ||||
|         public string CitizenshipByBirth { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.Gender"/> | ||||
|         public Gender Gender { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.MaritalStatus"/> | ||||
|         public MaritalStatus MaritalStatus { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.FatherName"/> | ||||
|         public Name FatherName { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.MotherName"/> | ||||
|         public Name MotherName { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.JobTitle"/> | ||||
|         public string JobTitle { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.PlaceOfWork"/> | ||||
|         public PlaceOfWork PlaceOfWork { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="Applicant.IsNonResident"/> | ||||
|         public bool IsNonResident { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -1,13 +0,0 @@ | ||||
| namespace ApplicationLayer.Services.Applicants.Models; | ||||
|  | ||||
| public class PlaceOfWorkModel | ||||
| { | ||||
|     /// Name of hirer | ||||
|     public string Name { get; set; } = null!; | ||||
|  | ||||
|     /// <see cref="AddressModel"/> of hirer | ||||
|     public AddressModel Address { get; set; } = null!; | ||||
|  | ||||
|     /// Phone number of hirer | ||||
|     public string PhoneNum { get; set; } = null!; | ||||
| } | ||||
| @@ -6,8 +6,12 @@ namespace ApplicationLayer.Services.VisaApplications.Handlers; | ||||
|  | ||||
| public interface IVisaApplicationRequestsHandler | ||||
| { | ||||
|     Task<List<VisaApplication>> Get(CancellationToken cancellationToken); | ||||
|     Task<List<VisaApplicationModelForApplicant>> GetForApplicant(Guid userId, CancellationToken cancellationToken); | ||||
|     /// Returns all applications for approving authorities | ||||
|     Task<List<VisaApplicationModelForAuthority>> GetAllAsync(CancellationToken cancellationToken); | ||||
|  | ||||
|     /// Returns all applications of one applicant | ||||
|     Task<List<VisaApplicationModelForApplicant>> GetForApplicantAsync(Guid userId, CancellationToken cancellationToken); | ||||
|  | ||||
|     /// Creates application for applicant with specific user identifier | ||||
|     Task HandleCreateRequest(Guid userId, VisaApplicationCreateRequest request, CancellationToken cancellationToken); | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,10 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using ApplicationLayer.Services.Applicants.Models; | ||||
| using ApplicationLayer.Services.Applicants.NeededServices; | ||||
| using ApplicationLayer.Services.VisaApplications.Models; | ||||
| using ApplicationLayer.Services.VisaApplications.NeededServices; | ||||
| using ApplicationLayer.Services.VisaApplications.Requests; | ||||
| using Domains.ApplicantDomain; | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Handlers; | ||||
| @@ -13,9 +15,57 @@ public class VisaApplicationRequestsHandler( | ||||
|     IApplicantsRepository applicants, | ||||
|     IUnitOfWork unitOfWork) : IVisaApplicationRequestsHandler | ||||
| { | ||||
|     public async Task<List<VisaApplication>> Get(CancellationToken cancellationToken) => await applications.GetAllAsync(cancellationToken); | ||||
|     async Task<List<VisaApplicationModelForAuthority>> IVisaApplicationRequestsHandler.GetAllAsync(CancellationToken cancellationToken) | ||||
|     { | ||||
|         var applicationsList = await applications.GetAllAsync(cancellationToken); | ||||
|  | ||||
|     public async Task<List<VisaApplicationModelForApplicant>> GetForApplicant(Guid userId, CancellationToken cancellationToken) | ||||
|         //todo mapper | ||||
|         var applicationModels = applicationsList | ||||
|             .Select(a => MapVisaApplicationToModelForAuthorities(a, cancellationToken).Result) | ||||
|             .ToList(); | ||||
|         return applicationModels; | ||||
|     } | ||||
|  | ||||
|     private async Task<VisaApplicationModelForAuthority> MapVisaApplicationToModelForAuthorities(VisaApplication visaApplication, | ||||
|         CancellationToken cancellationToken) | ||||
|     { | ||||
|         var applicant = await applicants.GetByIdAsync(visaApplication.ApplicantId, cancellationToken); | ||||
|         var applicantModel = new ApplicantModel | ||||
|         { | ||||
|             Citizenship = applicant.Citizenship, | ||||
|             Gender = applicant.Gender, | ||||
|             Name = applicant.Name, | ||||
|             Passport = applicant.Passport, | ||||
|             BirthDate = applicant.BirthDate, | ||||
|             FatherName = applicant.FatherName, | ||||
|             JobTitle = applicant.JobTitle, | ||||
|             MaritalStatus = applicant.MaritalStatus, | ||||
|             MotherName = applicant.MotherName, | ||||
|             CitizenshipByBirth = applicant.CitizenshipByBirth, | ||||
|             CityOfBirth = applicant.CityOfBirth, | ||||
|             CountryOfBirth = applicant.CountryOfBirth, | ||||
|             IsNonResident = applicant.IsNonResident, | ||||
|             PlaceOfWork = applicant.PlaceOfWork, | ||||
|         }; | ||||
|         return new VisaApplicationModelForAuthority | ||||
|         { | ||||
|             PastVisits = visaApplication.PastVisits, | ||||
|             ReentryPermit = visaApplication.ReentryPermit, | ||||
|             VisaCategory = visaApplication.VisaCategory, | ||||
|             PermissionToDestCountry = visaApplication.PermissionToDestCountry, | ||||
|             DestinationCountry = visaApplication.DestinationCountry, | ||||
|             PastVisas = visaApplication.PastVisas, | ||||
|             RequestDate = visaApplication.RequestDate, | ||||
|             ValidDaysRequested = visaApplication.ValidDaysRequested, | ||||
|             RequestedNumberOfEntries = visaApplication.RequestedNumberOfEntries, | ||||
|             ForGroup = visaApplication.ForGroup, | ||||
|             Applicant = applicantModel, | ||||
|             Id = visaApplication.Id, | ||||
|             Status = visaApplication.Status | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public async Task<List<VisaApplicationModelForApplicant>> GetForApplicantAsync(Guid userId, CancellationToken cancellationToken) | ||||
|     { | ||||
|         //todo mapper | ||||
|         var applicantId = await applicants.GetApplicantIdByUserId(userId, cancellationToken); | ||||
| @@ -31,8 +81,11 @@ public class VisaApplicationRequestsHandler( | ||||
|                 ForGroup = va.ForGroup, | ||||
|                 PastVisas = va.PastVisas, | ||||
|                 RequestDate = va.RequestDate, | ||||
|                 PastVisits = va.PastVisits | ||||
|             }).ToList(); | ||||
|                 PastVisits = va.PastVisits, | ||||
|                 Id = va.Id, | ||||
|                 Status = va.Status | ||||
|             }) | ||||
|             .ToList(); | ||||
|     } | ||||
|  | ||||
|     public async Task HandleCreateRequest(Guid userId, VisaApplicationCreateRequest request, CancellationToken cancellationToken) | ||||
| @@ -53,7 +106,8 @@ public class VisaApplicationRequestsHandler( | ||||
|             PastVisas = request.PastVisas.ToList(), | ||||
|             PastVisits = request.PastVisits.ToList(), | ||||
|             ForGroup = request.IsForGroup, | ||||
|             RequestDate = DateTime.Today | ||||
|             RequestDate = DateTime.Today, | ||||
|             Status = ApplicationStatus.Pending | ||||
|         }; | ||||
|  | ||||
|         await applications.AddAsync(visaApplication, cancellationToken); | ||||
|   | ||||
| @@ -5,6 +5,11 @@ namespace ApplicationLayer.Services.VisaApplications.Models | ||||
|     /// Model of <see cref="VisaApplication"/> | ||||
|     public class VisaApplicationModelForApplicant | ||||
|     { | ||||
|         /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|         public Guid Id { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|         public ApplicationStatus Status { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|         public ReentryPermit? ReentryPermit { get; set; } | ||||
|   | ||||
| @@ -0,0 +1,47 @@ | ||||
| using ApplicationLayer.Services.Applicants.Models; | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models | ||||
| { | ||||
|     /// Model of <see cref="VisaApplication"/> with applicant property | ||||
|     public class VisaApplicationModelForAuthority | ||||
|     { | ||||
|         /// <inheritdoc cref="VisaApplication.Id"/> | ||||
|         public Guid Id { get; set; } | ||||
|  | ||||
|         /// Applicant of application | ||||
|         public ApplicantModel Applicant { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.Status"/> | ||||
|         public ApplicationStatus Status { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ReentryPermit"/> | ||||
|         public ReentryPermit? ReentryPermit { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.DestinationCountry"/> | ||||
|         public string DestinationCountry { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PastVisas"/> | ||||
|         public List<PastVisa> PastVisas { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|         public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|         public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|         public VisaCategory VisaCategory { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ForGroup"/> | ||||
|         public bool ForGroup { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries"/> | ||||
|         public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.RequestDate"/> | ||||
|         public DateTime RequestDate { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.ValidDaysRequested"/> | ||||
|         public int ValidDaysRequested { get; set; } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user