Removed location entities, fixed configurations and controllers' comments
This commit is contained in:
		| @@ -1,6 +1,5 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using ApplicationLayer.Services.Applicants.NeededServices; | ||||
| using ApplicationLayer.Services.Locations.NeededServices; | ||||
| using ApplicationLayer.Services.VisaApplications.Models; | ||||
| using ApplicationLayer.Services.VisaApplications.NeededServices; | ||||
| using ApplicationLayer.Services.VisaApplications.Requests; | ||||
| @@ -12,7 +11,6 @@ namespace ApplicationLayer.Services.VisaApplications.Handlers; | ||||
| public class VisaApplicationRequestsHandler( | ||||
|     IVisaApplicationsRepository applications, | ||||
|     IApplicantsRepository applicants, | ||||
|     ICountriesRepository countries, | ||||
|     IUnitOfWork unitOfWork) : IVisaApplicationRequestsHandler | ||||
| { | ||||
|     public async Task<List<VisaApplication>> Get(CancellationToken cancellationToken) => await applications.GetAllAsync(cancellationToken); | ||||
| @@ -24,7 +22,7 @@ public class VisaApplicationRequestsHandler( | ||||
|         var visaApplications = await applications.GetOfApplicantAsync(applicantId, cancellationToken); | ||||
|         return visaApplications.Select(va => new VisaApplicationModelForApplicant | ||||
|             { | ||||
|                 DestinationCountry = va.DestinationCountry.Name, | ||||
|                 DestinationCountry = va.DestinationCountry, | ||||
|                 ValidDaysRequested = va.ValidDaysRequested, | ||||
|                 ReentryPermit = va.ReentryPermit, | ||||
|                 VisaCategory = va.VisaCategory, | ||||
| @@ -33,8 +31,7 @@ public class VisaApplicationRequestsHandler( | ||||
|                 ForGroup = va.ForGroup, | ||||
|                 PastVisas = va.PastVisas, | ||||
|                 RequestDate = va.RequestDate, | ||||
|                 PastVisits = va.PastVisits.Select(pv => | ||||
|                     new PastVisitModel { DestinationCountry = pv.DestinationCountry.Name, StartDate = pv.StartDate, EndDate = pv.EndDate }).ToList() | ||||
|                 PastVisits = va.PastVisits | ||||
|             }).ToList(); | ||||
|     } | ||||
|  | ||||
| @@ -44,18 +41,17 @@ public class VisaApplicationRequestsHandler( | ||||
|  | ||||
|         var applicant = await applicants.FindByUserIdAsync(userId, cancellationToken); | ||||
|  | ||||
|         var pastVisits = request.PastVisits.Select(m => ConvertPastVisitModelToPastVisit(m, cancellationToken).Result).ToList(); | ||||
|         var visaApplication = new VisaApplication | ||||
|         { | ||||
|             Applicant = applicant, | ||||
|             ApplicantId = applicant.Id, | ||||
|             RequestedNumberOfEntries = request.RequestedNumberOfEntries, | ||||
|             ValidDaysRequested = request.ValidDaysRequested, | ||||
|             ReentryPermit = request.ReentryPermit, | ||||
|             VisaCategory = request.VisaCategory, | ||||
|             PermissionToDestCountry = request.PermissionToDestCountry, | ||||
|             DestinationCountry = await countries.GetByIdAsync(request.DestinationCountryId, cancellationToken), | ||||
|             DestinationCountry = request.DestinationCountry, | ||||
|             PastVisas = request.PastVisas.ToList(), | ||||
|             PastVisits = pastVisits, | ||||
|             PastVisits = request.PastVisits.ToList(), | ||||
|             ForGroup = request.IsForGroup, | ||||
|             RequestDate = DateTime.Today | ||||
|         }; | ||||
| @@ -64,14 +60,4 @@ public class VisaApplicationRequestsHandler( | ||||
|  | ||||
|         await unitOfWork.SaveAsync(cancellationToken); | ||||
|     } | ||||
|  | ||||
|     private async Task<PastVisit> ConvertPastVisitModelToPastVisit(PastVisitModelForRequest modelForRequest, CancellationToken cancellationToken) | ||||
|     { | ||||
|         return new PastVisit | ||||
|         { | ||||
|             DestinationCountry = await countries.GetByIdAsync(modelForRequest.DestinationCountryId, cancellationToken), | ||||
|             StartDate = modelForRequest.StartDate, | ||||
|             EndDate = modelForRequest.EndDate | ||||
|         }; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,17 +0,0 @@ | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models | ||||
| { | ||||
|     /// Model of <see cref="PastVisit"/> with only name of the destination country | ||||
|     public class PastVisitModel | ||||
|     { | ||||
|         /// <inheritdoc cref="PastVisit.StartDate"/> | ||||
|         public DateTime StartDate { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="PastVisit.EndDate"/> | ||||
|         public DateTime EndDate { get; set; } | ||||
|  | ||||
|         /// <inheritdoc cref="PastVisit.DestinationCountry"/> | ||||
|         public string DestinationCountry { get; set; } = null!; | ||||
|     } | ||||
| } | ||||
| @@ -1,17 +0,0 @@ | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Models | ||||
| { | ||||
|     /// Model of <see cref="PastVisit"/> with only identifier of country | ||||
|     public class PastVisitModelForRequest | ||||
|     { | ||||
|         /// First day of <see cref="PastVisitModelForRequest"/> | ||||
|         public DateTime StartDate { get; set; } | ||||
|  | ||||
|         /// Last day of <see cref="PastVisitModelForRequest"/> | ||||
|         public DateTime EndDate { get; set; } | ||||
|  | ||||
|         /// Identifier of destination country of <see cref="PastVisitModelForRequest"/> | ||||
|         public Guid DestinationCountryId { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -18,7 +18,7 @@ namespace ApplicationLayer.Services.VisaApplications.Models | ||||
|         /// <inheritdoc cref="VisaApplication.PermissionToDestCountry"/> | ||||
|         public PermissionToDestCountry? PermissionToDestCountry { get; set; } | ||||
|  | ||||
|         public List<PastVisitModel> PastVisits { get; set; } = null!; | ||||
|         public List<PastVisit> PastVisits { get; set; } = null!; | ||||
|  | ||||
|         /// <inheritdoc cref="VisaApplication.VisaCategory"/> | ||||
|         public VisaCategory VisaCategory { get; set; } | ||||
|   | ||||
| @@ -1,17 +1,16 @@ | ||||
| using ApplicationLayer.Services.VisaApplications.Models; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using Domains.VisaApplicationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests; | ||||
|  | ||||
| /// Model of visa request from user | ||||
| public record VisaApplicationCreateRequest( | ||||
|     ReentryPermit ReentryPermit, | ||||
|     Guid DestinationCountryId, | ||||
|     string DestinationCountry, | ||||
|     VisaCategory VisaCategory, | ||||
|     bool IsForGroup, | ||||
|     RequestedNumberOfEntries RequestedNumberOfEntries, | ||||
|     int ValidDaysRequested, | ||||
|     PastVisa[] PastVisas, | ||||
|     PermissionToDestCountry? PermissionToDestCountry, | ||||
|     PastVisitModelForRequest[] PastVisits | ||||
|     PastVisit[] PastVisits | ||||
| ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user