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
|
public interface IVisaApplicationRequestsHandler
|
||||||
{
|
{
|
||||||
Task<List<VisaApplication>> Get(CancellationToken cancellationToken);
|
/// Returns all applications for approving authorities
|
||||||
Task<List<VisaApplicationModelForApplicant>> GetForApplicant(Guid userId, CancellationToken cancellationToken);
|
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);
|
Task HandleCreateRequest(Guid userId, VisaApplicationCreateRequest request, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||||
|
using ApplicationLayer.Services.Applicants.Models;
|
||||||
using ApplicationLayer.Services.Applicants.NeededServices;
|
using ApplicationLayer.Services.Applicants.NeededServices;
|
||||||
using ApplicationLayer.Services.VisaApplications.Models;
|
using ApplicationLayer.Services.VisaApplications.Models;
|
||||||
using ApplicationLayer.Services.VisaApplications.NeededServices;
|
using ApplicationLayer.Services.VisaApplications.NeededServices;
|
||||||
using ApplicationLayer.Services.VisaApplications.Requests;
|
using ApplicationLayer.Services.VisaApplications.Requests;
|
||||||
|
using Domains.ApplicantDomain;
|
||||||
using Domains.VisaApplicationDomain;
|
using Domains.VisaApplicationDomain;
|
||||||
|
|
||||||
namespace ApplicationLayer.Services.VisaApplications.Handlers;
|
namespace ApplicationLayer.Services.VisaApplications.Handlers;
|
||||||
@@ -13,9 +15,57 @@ public class VisaApplicationRequestsHandler(
|
|||||||
IApplicantsRepository applicants,
|
IApplicantsRepository applicants,
|
||||||
IUnitOfWork unitOfWork) : IVisaApplicationRequestsHandler
|
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
|
//todo mapper
|
||||||
var applicantId = await applicants.GetApplicantIdByUserId(userId, cancellationToken);
|
var applicantId = await applicants.GetApplicantIdByUserId(userId, cancellationToken);
|
||||||
@@ -31,8 +81,11 @@ public class VisaApplicationRequestsHandler(
|
|||||||
ForGroup = va.ForGroup,
|
ForGroup = va.ForGroup,
|
||||||
PastVisas = va.PastVisas,
|
PastVisas = va.PastVisas,
|
||||||
RequestDate = va.RequestDate,
|
RequestDate = va.RequestDate,
|
||||||
PastVisits = va.PastVisits
|
PastVisits = va.PastVisits,
|
||||||
}).ToList();
|
Id = va.Id,
|
||||||
|
Status = va.Status
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleCreateRequest(Guid userId, VisaApplicationCreateRequest request, CancellationToken cancellationToken)
|
public async Task HandleCreateRequest(Guid userId, VisaApplicationCreateRequest request, CancellationToken cancellationToken)
|
||||||
@@ -53,7 +106,8 @@ public class VisaApplicationRequestsHandler(
|
|||||||
PastVisas = request.PastVisas.ToList(),
|
PastVisas = request.PastVisas.ToList(),
|
||||||
PastVisits = request.PastVisits.ToList(),
|
PastVisits = request.PastVisits.ToList(),
|
||||||
ForGroup = request.IsForGroup,
|
ForGroup = request.IsForGroup,
|
||||||
RequestDate = DateTime.Today
|
RequestDate = DateTime.Today,
|
||||||
|
Status = ApplicationStatus.Pending
|
||||||
};
|
};
|
||||||
|
|
||||||
await applications.AddAsync(visaApplication, cancellationToken);
|
await applications.AddAsync(visaApplication, cancellationToken);
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ namespace ApplicationLayer.Services.VisaApplications.Models
|
|||||||
/// Model of <see cref="VisaApplication"/>
|
/// Model of <see cref="VisaApplication"/>
|
||||||
public class VisaApplicationModelForApplicant
|
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"/>
|
/// <inheritdoc cref="VisaApplication.ReentryPermit"/>
|
||||||
public ReentryPermit? ReentryPermit { get; set; }
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Domains.VisaApplicationDomain
|
||||||
|
{
|
||||||
|
public enum ApplicationStatus
|
||||||
|
{
|
||||||
|
/// Waits for approve
|
||||||
|
Pending,
|
||||||
|
Approved,
|
||||||
|
Rejected,
|
||||||
|
/// Closed by applicant
|
||||||
|
Closed
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,9 @@ public class VisaApplication : IEntity
|
|||||||
/// Identifier of the <see cref="Applicant"/>
|
/// Identifier of the <see cref="Applicant"/>
|
||||||
public Guid ApplicantId { get; set; }
|
public Guid ApplicantId { get; set; }
|
||||||
|
|
||||||
|
/// Status of application
|
||||||
|
public ApplicationStatus Status { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc cref="Domains.VisaApplicationDomain.ReentryPermit"/>
|
/// <inheritdoc cref="Domains.VisaApplicationDomain.ReentryPermit"/>
|
||||||
/// <remarks>always null if <see cref="Applicant"/> is not a non-resident</remarks>
|
/// <remarks>always null if <see cref="Applicant"/> is not a non-resident</remarks>
|
||||||
public ReentryPermit? ReentryPermit { get; set; }
|
public ReentryPermit? ReentryPermit { get; set; }
|
||||||
@@ -18,9 +21,7 @@ public class VisaApplication : IEntity
|
|||||||
/// Country that <see cref="Applicant"/> wants to visit
|
/// Country that <see cref="Applicant"/> wants to visit
|
||||||
public string DestinationCountry { get; set; } = null!;
|
public string DestinationCountry { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of <see cref="PastVisa"/> that applicant had before
|
/// List of <see cref="PastVisa"/> that applicant had before
|
||||||
/// </summary>
|
|
||||||
public List<PastVisa> PastVisas { get; set; } = null!;
|
public List<PastVisa> PastVisas { get; set; } = null!;
|
||||||
|
|
||||||
/// Permission to enter the destination country of <see cref="Applicant"/>
|
/// Permission to enter the destination country of <see cref="Applicant"/>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Security.Claims;
|
|
||||||
using ApplicationLayer.Services.VisaApplications.Handlers;
|
using ApplicationLayer.Services.VisaApplications.Handlers;
|
||||||
using ApplicationLayer.Services.VisaApplications.Models;
|
using ApplicationLayer.Services.VisaApplications.Models;
|
||||||
using ApplicationLayer.Services.VisaApplications.Requests;
|
using ApplicationLayer.Services.VisaApplications.Requests;
|
||||||
@@ -14,18 +13,17 @@ namespace SchengenVisaApi.Controllers;
|
|||||||
[Route("visaApplication")]
|
[Route("visaApplication")]
|
||||||
public class VisaApplicationController(IVisaApplicationRequestsHandler visaApplicationRequestsHandler) : VisaApiControllerBase
|
public class VisaApplicationController(IVisaApplicationRequestsHandler visaApplicationRequestsHandler) : VisaApiControllerBase
|
||||||
{
|
{
|
||||||
//todo should return only pending applications
|
|
||||||
//todo should return model
|
//todo should return model
|
||||||
/// <summary> Returns all applications from DB </summary>
|
/// <summary> Returns all applications from DB </summary>
|
||||||
/// <remarks> Accessible only for approving authorities </remarks>
|
/// <remarks> Accessible only for approving authorities </remarks>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType<List<VisaApplication>>(StatusCodes.Status200OK)]
|
[ProducesResponseType<List<VisaApplicationModelForAuthority>>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
||||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = await visaApplicationRequestsHandler.Get(cancellationToken);
|
var result = await visaApplicationRequestsHandler.GetAllAsync(cancellationToken);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +39,7 @@ public class VisaApplicationController(IVisaApplicationRequestsHandler visaAppli
|
|||||||
public async Task<IActionResult> GetForApplicant(CancellationToken cancellationToken)
|
public async Task<IActionResult> GetForApplicant(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var userId = GetUserId();
|
var userId = GetUserId();
|
||||||
var result = await visaApplicationRequestsHandler.GetForApplicant(userId, cancellationToken);
|
var result = await visaApplicationRequestsHandler.GetForApplicantAsync(userId, cancellationToken);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user