Page for seeing full application
This commit is contained in:
@@ -6,10 +6,16 @@ namespace ApplicationLayer.Services.VisaApplications.Handlers;
|
|||||||
public interface IVisaApplicationRequestsHandler
|
public interface IVisaApplicationRequestsHandler
|
||||||
{
|
{
|
||||||
/// Returns all applications for approving authorities
|
/// Returns all applications for approving authorities
|
||||||
Task<List<VisaApplicationModelForAuthority>> GetPendingAsync(CancellationToken cancellationToken);
|
Task<List<VisaApplicationPreview>> GetPendingAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// Returns all applications of one applicant
|
/// Returns all applications of one applicant
|
||||||
Task<List<VisaApplicationModelForApplicant>> GetForApplicantAsync(CancellationToken cancellationToken);
|
Task<List<VisaApplicationPreview>> GetForApplicantAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// Returns one application with specific id
|
||||||
|
Task<VisaApplicationModel> GetApplicationForApplicantAsync(Guid id, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// Returns one application with specific id
|
||||||
|
Task<VisaApplicationModel> GetApplicationForAuthorityAsync(Guid id, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// Creates application for applicant with specific user identifier
|
/// Creates application for applicant with specific user identifier
|
||||||
Task HandleCreateRequestAsync(VisaApplicationCreateRequest request, CancellationToken cancellationToken);
|
Task HandleCreateRequestAsync(VisaApplicationCreateRequest request, CancellationToken cancellationToken);
|
||||||
|
|||||||
@@ -19,24 +19,41 @@ public class VisaApplicationRequestsHandler(
|
|||||||
IDateTimeProvider dateTimeProvider,
|
IDateTimeProvider dateTimeProvider,
|
||||||
IUserIdProvider userIdProvider) : IVisaApplicationRequestsHandler
|
IUserIdProvider userIdProvider) : IVisaApplicationRequestsHandler
|
||||||
{
|
{
|
||||||
async Task<List<VisaApplicationModelForAuthority>> IVisaApplicationRequestsHandler.GetPendingAsync(CancellationToken cancellationToken)
|
async Task<List<VisaApplicationPreview>> IVisaApplicationRequestsHandler.GetPendingAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var applicationsList = await applications.GetPendingApplicationsAsync(cancellationToken);
|
var applicationsList = await applications.GetPendingApplicationsAsync(cancellationToken);
|
||||||
|
|
||||||
var applicationModels = applicationsList
|
var applicationModels = mapper.Map<List<VisaApplicationPreview>>(applicationsList);
|
||||||
.Select(a => MapVisaApplicationToModelForAuthorities(a, cancellationToken).Result)
|
|
||||||
.ToList();
|
|
||||||
return applicationModels;
|
return applicationModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<VisaApplicationModelForApplicant>> GetForApplicantAsync(CancellationToken cancellationToken)
|
async Task<List<VisaApplicationPreview>> IVisaApplicationRequestsHandler.GetForApplicantAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var applicantId = await applicants.GetApplicantIdByUserId(userIdProvider.GetUserId(), cancellationToken);
|
var applicantId = await applicants.GetApplicantIdByUserId(userIdProvider.GetUserId(), cancellationToken);
|
||||||
var visaApplications = await applications.GetOfApplicantAsync(applicantId, cancellationToken);
|
var visaApplications = await applications.GetOfApplicantAsync(applicantId, cancellationToken);
|
||||||
return mapper.Map<List<VisaApplicationModelForApplicant>>(visaApplications);
|
return mapper.Map<List<VisaApplicationPreview>>(visaApplications);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleCreateRequestAsync(VisaApplicationCreateRequest request, CancellationToken cancellationToken)
|
async Task<VisaApplicationModel> IVisaApplicationRequestsHandler.GetApplicationForApplicantAsync(Guid id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var applicant = await applicants.FindByUserIdAsync(userIdProvider.GetUserId(), cancellationToken);
|
||||||
|
var application = await applications.GetByApplicantAndApplicationIdAsync(applicant.Id, id, cancellationToken);
|
||||||
|
var mapped = mapper.Map<VisaApplicationModel>(application);
|
||||||
|
mapped.Applicant = mapper.Map<ApplicantModel>(applicant);
|
||||||
|
return mapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task<VisaApplicationModel> IVisaApplicationRequestsHandler.GetApplicationForAuthorityAsync(Guid id, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var pending = await applications.GetPendingApplicationsAsync(cancellationToken);
|
||||||
|
var application = pending.SingleOrDefault(a => a.Id == id) ?? throw new ApplicationAlreadyProcessedException();
|
||||||
|
var mapped = mapper.Map<VisaApplicationModel>(application);
|
||||||
|
var applicant = await applicants.GetByIdAsync(application.ApplicantId, cancellationToken);
|
||||||
|
mapped.Applicant = mapper.Map<ApplicantModel>(applicant);
|
||||||
|
return mapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task IVisaApplicationRequestsHandler.HandleCreateRequestAsync(VisaApplicationCreateRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var applicant = await applicants.FindByUserIdAsync(userIdProvider.GetUserId(), cancellationToken);
|
var applicant = await applicants.FindByUserIdAsync(userIdProvider.GetUserId(), cancellationToken);
|
||||||
|
|
||||||
@@ -87,16 +104,4 @@ public class VisaApplicationRequestsHandler(
|
|||||||
|
|
||||||
await unitOfWork.SaveAsync(cancellationToken);
|
await unitOfWork.SaveAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<VisaApplicationModelForAuthority> MapVisaApplicationToModelForAuthorities(VisaApplication visaApplication,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var applicant = await applicants.GetByIdAsync(visaApplication.ApplicantId, cancellationToken);
|
|
||||||
var applicantModel = mapper.Map<ApplicantModel>(applicant);
|
|
||||||
|
|
||||||
var model = mapper.Map<VisaApplicationModelForAuthority>(visaApplication);
|
|
||||||
model.Applicant = applicantModel;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using Domains.VisaApplicationDomain;
|
|||||||
namespace ApplicationLayer.Services.VisaApplications.Models;
|
namespace ApplicationLayer.Services.VisaApplications.Models;
|
||||||
|
|
||||||
/// Model of <see cref="VisaApplication" /> with applicant property
|
/// Model of <see cref="VisaApplication" /> with applicant property
|
||||||
public class VisaApplicationModelForAuthority
|
public class VisaApplicationModel
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="VisaApplication.Id" />
|
/// <inheritdoc cref="VisaApplication.Id" />
|
||||||
[Required]
|
[Required]
|
||||||
@@ -4,7 +4,7 @@ using Domains.VisaApplicationDomain;
|
|||||||
namespace ApplicationLayer.Services.VisaApplications.Models;
|
namespace ApplicationLayer.Services.VisaApplications.Models;
|
||||||
|
|
||||||
/// Model of <see cref="VisaApplication" />
|
/// Model of <see cref="VisaApplication" />
|
||||||
public class VisaApplicationModelForApplicant
|
public class VisaApplicationPreview
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="VisaApplication.Id" />
|
/// <inheritdoc cref="VisaApplication.Id" />
|
||||||
[Required]
|
[Required]
|
||||||
@@ -14,36 +14,14 @@ public class VisaApplicationModelForApplicant
|
|||||||
[Required]
|
[Required]
|
||||||
public ApplicationStatus Status { get; set; }
|
public ApplicationStatus Status { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.ReentryPermit" />
|
|
||||||
public ReentryPermitModel? ReentryPermit { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.DestinationCountry" />
|
/// <inheritdoc cref="VisaApplication.DestinationCountry" />
|
||||||
[Required]
|
[Required]
|
||||||
public string DestinationCountry { get; set; } = null!;
|
public string DestinationCountry { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.PastVisas" />
|
|
||||||
[Required]
|
|
||||||
public List<PastVisaModel> PastVisas { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.PermissionToDestCountry" />
|
|
||||||
public PermissionToDestCountryModel? PermissionToDestCountry { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.PastVisits" />
|
|
||||||
[Required]
|
|
||||||
public List<PastVisitModel> PastVisits { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.VisaCategory" />
|
/// <inheritdoc cref="VisaApplication.VisaCategory" />
|
||||||
[Required]
|
[Required]
|
||||||
public VisaCategory VisaCategory { get; set; }
|
public VisaCategory VisaCategory { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.ForGroup" />
|
|
||||||
[Required]
|
|
||||||
public bool ForGroup { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" />
|
|
||||||
[Required]
|
|
||||||
public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc cref="VisaApplication.RequestDate" />
|
/// <inheritdoc cref="VisaApplication.RequestDate" />
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime RequestDate { get; set; }
|
public DateTime RequestDate { get; set; }
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BlazorWebAssemblyVisaApiClient.Common
|
namespace BlazorWebAssemblyVisaApiClient.Common.Exceptions
|
||||||
{
|
{
|
||||||
public class BlazorClientException(string message) : Exception(message);
|
public class BlazorClientException(string message) : Exception(message);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
namespace BlazorWebAssemblyVisaApiClient.Common.Exceptions
|
||||||
|
{
|
||||||
|
public class NotLoggedInException() : BlazorClientException("User is not logged in.");
|
||||||
|
}
|
||||||
@@ -12,5 +12,9 @@ namespace BlazorWebAssemblyVisaApiClient
|
|||||||
public readonly static Regex PhoneNumRegex = new(@"^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$");
|
public readonly static Regex PhoneNumRegex = new(@"^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$");
|
||||||
|
|
||||||
public readonly static MarkupString RequiredFieldMarkup = (MarkupString)"<span style=\"color: red;\">*</span>";
|
public readonly static MarkupString RequiredFieldMarkup = (MarkupString)"<span style=\"color: red;\">*</span>";
|
||||||
|
|
||||||
|
public const string ApplicantRole = "Applicant";
|
||||||
|
public const string ApprovingAuthorityRole = "ApprovingAuthority";
|
||||||
|
public const string AdminRole = "Admin";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using BlazorWebAssemblyVisaApiClient.Common;
|
using BlazorWebAssemblyVisaApiClient.Common.Exceptions;
|
||||||
|
|
||||||
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions
|
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
|
|||||||
{
|
{
|
||||||
public class UserDataProvider(Client client) : IUserDataProvider
|
public class UserDataProvider(Client client) : IUserDataProvider
|
||||||
{
|
{
|
||||||
private readonly static JwtSecurityTokenHandler tokenHandler = new ();
|
private readonly static JwtSecurityTokenHandler tokenHandler = new();
|
||||||
private readonly static string[] knownRoles = ["Applicant", "ApprovingAuthority", "Admin"];
|
|
||||||
|
|
||||||
public async Task<ApplicantModel> GetApplicant()
|
public async Task<ApplicantModel> GetApplicant()
|
||||||
{
|
{
|
||||||
@@ -25,9 +24,12 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
|
|||||||
var token = tokenHandler.ReadJwtToken(client.AuthToken.Token);
|
var token = tokenHandler.ReadJwtToken(client.AuthToken.Token);
|
||||||
var role = token.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Role)?.Value;
|
var role = token.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Role)?.Value;
|
||||||
|
|
||||||
if (!knownRoles.Contains(role))
|
switch (role)
|
||||||
{
|
{
|
||||||
throw new UnknownRoleException();
|
case Constants.ApplicantRole: break;
|
||||||
|
case Constants.ApprovingAuthorityRole: break;
|
||||||
|
case Constants.AdminRole: break;
|
||||||
|
default: throw new UnknownRoleException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return role;
|
return role;
|
||||||
|
|||||||
@@ -0,0 +1,213 @@
|
|||||||
|
@page "/applications/{ApplicationId}"
|
||||||
|
@using BlazorWebAssemblyVisaApiClient.Common.Exceptions
|
||||||
|
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
|
||||||
|
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
|
||||||
|
@using VisaApiClient
|
||||||
|
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
|
||||||
|
|
||||||
|
<PageTitle>Application</PageTitle>
|
||||||
|
|
||||||
|
<table class="table table-bordered table-hover table-sm">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
Applicant's fullname:<br/>
|
||||||
|
<em>@NameToString(application.Applicant.Name)</em>
|
||||||
|
</td>
|
||||||
|
<td colspan="2">
|
||||||
|
Date of birth:<br/>
|
||||||
|
<em>@application.Applicant.BirthDate.ToString("d")</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Country and city of birth:<br/>
|
||||||
|
<em>@application.Applicant.Passport.Number</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
Citizenship:<br/>
|
||||||
|
<em>@application.Applicant.Citizenship</em>
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
Citizenship by birth:<br/>
|
||||||
|
<em>@application.Applicant.CitizenshipByBirth</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
Gender:<br/>
|
||||||
|
<em>@application.Applicant.Gender.GetDisplayName()</em>
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
Marital status:<br/>
|
||||||
|
<em>@application.Applicant.MaritalStatus.GetDisplayName()</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
Father's fullname:<br/>
|
||||||
|
<em>@NameToString(application.Applicant.FatherName)</em>
|
||||||
|
</td>
|
||||||
|
<td colspan="2">
|
||||||
|
Mother's fullname:<br/>
|
||||||
|
<em>@NameToString(application.Applicant.MotherName)</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
Passport number:<br/>
|
||||||
|
<em>@application.Applicant.Passport.Number</em>
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
Issue date:<br/>
|
||||||
|
<em>@application.Applicant.Passport.IssueDate.ToString("d")</em>
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
Expiration date:<br/>
|
||||||
|
<em>@application.Applicant.Passport.ExpirationDate.ToString("d")</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Passport issuer:<br/>
|
||||||
|
<em>@application.Applicant.Passport.Issuer</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Re-entry permission (for non-residents):<br/>
|
||||||
|
@if (application.Applicant.IsNonResident)
|
||||||
|
{
|
||||||
|
<em>@(application.ReentryPermit is null ? "None" : $"{application.ReentryPermit.Number}, expires at {application.ReentryPermit.ExpirationDate:d}")</em>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<em>Not non-resident</em>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Job title:<br/>
|
||||||
|
<em>@application.Applicant.JobTitle</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Place of work, address, hirer's phone number:<br/>
|
||||||
|
<em>
|
||||||
|
@((MarkupString)$"{application.Applicant.PlaceOfWork.Name}<br>Address: {AddressToString(application.Applicant.PlaceOfWork.Address)}<br>Phone num: {application.Applicant.PlaceOfWork.PhoneNum}")
|
||||||
|
</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
Destination Country:<br/>
|
||||||
|
<em>@application.DestinationCountry</em>
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
Visa category:<br/>
|
||||||
|
<em>@application.VisaCategory</em>
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
Visa:<br/>
|
||||||
|
<em>@(application.ForGroup ? "For group" : "Individual")</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
Requested number of entries:<br/>
|
||||||
|
<em>@application.RequestedNumberOfEntries.GetDisplayName()</em>
|
||||||
|
</td>
|
||||||
|
<td colspan="2">
|
||||||
|
Valid for:<br/>
|
||||||
|
<em>@($"{application.ValidDaysRequested} days")</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Past visas:<br/>
|
||||||
|
@if (application.PastVisas.Any())
|
||||||
|
{
|
||||||
|
foreach (var visa in application.PastVisas)
|
||||||
|
{
|
||||||
|
<em>@($"{visa.Name} issued at {visa.IssueDate:d} and was valid until {visa.ExpirationDate:d}")</em>
|
||||||
|
<br/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<em>None</em>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Permission to destination Country, if transit:<br/>
|
||||||
|
@if (application.VisaCategory is VisaCategory.Transit)
|
||||||
|
{
|
||||||
|
<em>@(application.PermissionToDestCountry is null ? "None" : $"Expires at {application.PermissionToDestCountry.ExpirationDate}, issued by: {application.PermissionToDestCountry.Issuer}")</em>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<em>Non-transit</em>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
Past visits:<br/>
|
||||||
|
@if (application.PastVisas.Any())
|
||||||
|
{
|
||||||
|
foreach (var visit in application.PastVisits)
|
||||||
|
{
|
||||||
|
<em>@($"Visit to {visit.DestinationCountry}, entered at {visit.StartDate:d} and lasts until {visit.EndDate:d}")</em>
|
||||||
|
<br/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<em>None</em>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private VisaApplicationModel application = new();
|
||||||
|
private string currentRole = null!;
|
||||||
|
|
||||||
|
[Parameter] public string ApplicationId { get; set; } = null!;
|
||||||
|
|
||||||
|
[Inject] private IUserDataProvider UserDataProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var applicationId = Guid.Parse(ApplicationId);
|
||||||
|
currentRole = UserDataProvider.GetCurrentRole() ?? throw new NotLoggedInException();
|
||||||
|
|
||||||
|
application = currentRole switch
|
||||||
|
{
|
||||||
|
Constants.ApplicantRole => await Client.GetApplicationForApplicantAsync(applicationId),
|
||||||
|
Constants.ApprovingAuthorityRole => await Client.GetApplicationForAuthorityAsync(applicationId),
|
||||||
|
_ => throw new NotLoggedInException()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ErrorHandler.Handle(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string NameToString(NameModel name)
|
||||||
|
=> $"{name.FirstName} {name.Surname} {name.Patronymic}".TrimEnd();
|
||||||
|
|
||||||
|
private static string AddressToString(AddressModel address)
|
||||||
|
=> $"{address.Country}, {address.City}, {address.Street} {address.Building}";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,68 +1,62 @@
|
|||||||
@page "/applications"
|
@page "/applications"
|
||||||
@using System.Reflection
|
|
||||||
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
|
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
|
||||||
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
|
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
|
||||||
@using BlazorWebAssemblyVisaApiClient.PagesExceptions.Applications
|
|
||||||
@using VisaApiClient
|
@using VisaApiClient
|
||||||
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
|
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
|
||||||
|
|
||||||
<PageTitle>Applications</PageTitle>
|
<PageTitle>Applications</PageTitle>
|
||||||
|
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered table-hover">
|
||||||
@switch (currentRole)
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Destination Country</th>
|
||||||
|
<th>Visa Category</th>
|
||||||
|
<th>Request date</th>
|
||||||
|
<th>Days requested</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach (var application in applications)
|
||||||
{
|
{
|
||||||
case "Applicant":
|
var rowClass = application.Status switch
|
||||||
<thead>
|
{
|
||||||
<tr>
|
ApplicationStatus.Pending => "",
|
||||||
<th>Destination Country</th>
|
ApplicationStatus.Approved => "table-success",
|
||||||
<th>Visa Category</th>
|
ApplicationStatus.Rejected => "table-danger",
|
||||||
<th>Request date</th>
|
ApplicationStatus.Closed => "table-danger",
|
||||||
<th>Days requested</th>
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
<th>Status</th>
|
};
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
<tr class="@rowClass">
|
||||||
@foreach (var application in applications.Cast<VisaApplicationModelForApplicant>())
|
<td>@application.DestinationCountry</td>
|
||||||
{
|
<td>@application.VisaCategory.GetDisplayName()</td>
|
||||||
var rowClass = application.Status switch
|
<td>@application.RequestDate.ToString("d")</td>
|
||||||
|
<td>@application.ValidDaysRequested</td>
|
||||||
|
<td>@application.Status.GetDisplayName()</td>
|
||||||
|
<td>
|
||||||
|
<NavLink href="@($"/applications/{application.Id}")">
|
||||||
|
<button class="btn-outline-primary">See</button>
|
||||||
|
</NavLink>
|
||||||
|
@if (currentRole == Constants.ApplicantRole && application.Status is not ApplicationStatus.Closed)
|
||||||
{
|
{
|
||||||
ApplicationStatus.Pending => "",
|
<span> | </span>
|
||||||
ApplicationStatus.Approved => "table-success",
|
<input type="button" class="border-danger" @onclick="() => CloseApplication(application)" value="Close"/>
|
||||||
ApplicationStatus.Rejected => "table-danger",
|
}
|
||||||
ApplicationStatus.Closed => "table-danger",
|
</td>
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
</tr>
|
||||||
};
|
|
||||||
|
|
||||||
<tr class="@rowClass">
|
|
||||||
<th>@application.DestinationCountry</th>
|
|
||||||
<th>@application.VisaCategory.GetDisplayName()</th>
|
|
||||||
<th>@application.RequestDate.ToString("d")</th>
|
|
||||||
<th>@application.ValidDaysRequested</th>
|
|
||||||
<th>@application.Status.GetDisplayName()</th>
|
|
||||||
<th>
|
|
||||||
<input type="button" class="border-danger" @onclick="() => CloseApplication(application)" value="Close"/>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Nav.NavigateTo("/"); //todo feedback
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
</tbody>
|
||||||
</table >
|
</table >
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string currentRole = null!;
|
private string currentRole = null!;
|
||||||
private IEnumerable<object> applications = [];
|
private List<VisaApplicationPreview> applications = [];
|
||||||
|
|
||||||
[Inject] private IUserDataProvider UserDataProvider { get; set; } = null!;
|
[Inject] private IUserDataProvider UserDataProvider { get; set; } = null!;
|
||||||
|
|
||||||
[Inject] private NavigationManager Nav { get; set; } = null!;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
currentRole = UserDataProvider.GetCurrentRole()!;
|
currentRole = UserDataProvider.GetCurrentRole()!;
|
||||||
@@ -75,7 +69,8 @@
|
|||||||
{
|
{
|
||||||
applications = currentRole switch
|
applications = currentRole switch
|
||||||
{
|
{
|
||||||
"Applicant" => (await Client.GetForApplicantAsync()).OrderByDescending(a => a.RequestDate),
|
Constants.ApplicantRole => (await Client.GetForApplicantAsync()).OrderByDescending(a => a.RequestDate).ToList(),
|
||||||
|
Constants.ApprovingAuthorityRole => (await Client.GetPendingAsync()).OrderByDescending(a => a.RequestDate).ToList(),
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -85,39 +80,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CloseApplication(object application)
|
private async Task CloseApplication(VisaApplicationPreview application)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PropertyInfo idProp;
|
await Client.CloseApplicationAsync(application.Id);
|
||||||
PropertyInfo statusProp;
|
application.Status = ApplicationStatus.Closed;
|
||||||
try
|
|
||||||
{
|
|
||||||
var type = applications.First().GetType();
|
|
||||||
idProp = type.GetProperty("Id")!;
|
|
||||||
statusProp = type.GetProperty("Status")!;
|
|
||||||
if (idProp.PropertyType != typeof(Guid)
|
|
||||||
|| statusProp.PropertyType != typeof(ApplicationStatus))
|
|
||||||
{
|
|
||||||
throw new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw new UnknownApplicationTypeException();
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = (Guid)idProp.GetValue(application)!;
|
|
||||||
await Client.CloseApplicationAsync(id);
|
|
||||||
|
|
||||||
statusProp.SetValue(application, ApplicationStatus.Closed);
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ErrorHandler.Handle(e);
|
ErrorHandler.Handle(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<h5>Past visas</h5>
|
<h5>Past visas</h5>
|
||||||
@if (requestModel.PastVisas.Count > 0)
|
@if (requestModel.PastVisas.Count > 0)
|
||||||
{
|
{
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th><th>Issue date</th><th>Expiration date</th><th></th>
|
<th>Name</th><th>Issue date</th><th>Expiration date</th><th></th>
|
||||||
@@ -68,12 +68,12 @@
|
|||||||
@foreach (var visa in requestModel.PastVisas)
|
@foreach (var visa in requestModel.PastVisas)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<th>@visa.Name</th>
|
<td>@visa.Name</td>
|
||||||
<th>@visa.IssueDate.ToString("d.MM.yyyy")</th>
|
<td>@visa.IssueDate.ToString("d.MM.yyyy")</td>
|
||||||
<th>@visa.ExpirationDate.ToString("d.MM.yyyy")</th>
|
<td>@visa.ExpirationDate.ToString("d.MM.yyyy")</td>
|
||||||
<th>
|
<td>
|
||||||
<input type="button" class="border-danger" @onclick="() => RemovePastVisa(visa)" value="X"/>
|
<input type="button" class="border-danger" @onclick="() => RemovePastVisa(visa)" value="X"/>
|
||||||
</th>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
<h5>Past visits</h5>
|
<h5>Past visits</h5>
|
||||||
@if (requestModel.PastVisits.Count > 0)
|
@if (requestModel.PastVisits.Count > 0)
|
||||||
{
|
{
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Destination Country</th><th>Start date</th><th>End date</th><th></th>
|
<th>Destination Country</th><th>Start date</th><th>End date</th><th></th>
|
||||||
@@ -122,12 +122,12 @@
|
|||||||
@foreach (var visit in requestModel.PastVisits)
|
@foreach (var visit in requestModel.PastVisits)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<th>@visit.DestinationCountry</th>
|
<td>@visit.DestinationCountry</td>
|
||||||
<th>@visit.StartDate.ToString("d.MM.yyyy")</th>
|
<td>@visit.StartDate.ToString("d.MM.yyyy")</td>
|
||||||
<th>@visit.EndDate.ToString("d.MM.yyyy")</th>
|
<td>@visit.EndDate.ToString("d.MM.yyyy")</td>
|
||||||
<th>
|
<td>
|
||||||
<input type="button" class="border-danger" @onclick="() => RemovePastVisit(visit)" value="X"/>
|
<input type="button" class="border-danger" @onclick="() => RemovePastVisit(visit)" value="X"/>
|
||||||
</th>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
using BlazorWebAssemblyVisaApiClient.Common;
|
|
||||||
|
|
||||||
namespace BlazorWebAssemblyVisaApiClient.PagesExceptions.Applications
|
|
||||||
{
|
|
||||||
public class UnknownApplicationTypeException() : BlazorClientException("Application type is unknown");
|
|
||||||
}
|
|
||||||
@@ -9,9 +9,9 @@ public class VisaApplicationProfile : Profile
|
|||||||
{
|
{
|
||||||
public VisaApplicationProfile()
|
public VisaApplicationProfile()
|
||||||
{
|
{
|
||||||
CreateMap<VisaApplication, VisaApplicationModelForApplicant>(MemberList.Destination);
|
CreateMap<VisaApplication, VisaApplicationPreview>(MemberList.Destination);
|
||||||
|
|
||||||
CreateMap<VisaApplication, VisaApplicationModelForAuthority>(MemberList.Destination)
|
CreateMap<VisaApplication, VisaApplicationModel>(MemberList.Destination)
|
||||||
.ForMember(model => model.Applicant,
|
.ForMember(model => model.Applicant,
|
||||||
opts => opts.Ignore());
|
opts => opts.Ignore());
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class VisaApplicationController(
|
|||||||
/// <summary> Returns pending applications </summary>
|
/// <summary> Returns pending applications </summary>
|
||||||
/// <remarks> Accessible only for approving authorities </remarks>
|
/// <remarks> Accessible only for approving authorities </remarks>
|
||||||
[HttpGet("pending")]
|
[HttpGet("pending")]
|
||||||
[ProducesResponseType<List<VisaApplicationModelForAuthority>>(StatusCodes.Status200OK)]
|
[ProducesResponseType<List<VisaApplicationPreview>>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
||||||
@@ -28,10 +28,38 @@ public class VisaApplicationController(
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns application </summary>
|
||||||
|
/// <remarks> Accessible only for approving authorities </remarks>
|
||||||
|
[HttpGet("/forAuthority/{applicationId:guid}")]
|
||||||
|
[ProducesResponseType<VisaApplicationModel>(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
||||||
|
public async Task<IActionResult> GetApplicationForAuthority(Guid applicationId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var result = await visaApplicationRequestsHandler.GetApplicationForAuthorityAsync(applicationId, cancellationToken);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns application </summary>
|
||||||
|
/// <remarks> Accessible only for applicant </remarks>
|
||||||
|
[HttpGet("/forApplicant/{applicationId:guid}")]
|
||||||
|
[ProducesResponseType<VisaApplicationModel>(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[Authorize(policy: PolicyConstants.ApplicantPolicy)]
|
||||||
|
public async Task<IActionResult> GetApplicationForApplicant(Guid applicationId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var result = await visaApplicationRequestsHandler.GetApplicationForApplicantAsync(applicationId, cancellationToken);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Returns all applications of one applicant </summary>
|
/// <summary> Returns all applications of one applicant </summary>
|
||||||
/// <remarks> Returns applications of authorized applicant </remarks>
|
/// <remarks> Returns applications of authorized applicant </remarks>
|
||||||
[HttpGet("ofApplicant")]
|
[HttpGet("ofApplicant")]
|
||||||
[ProducesResponseType<List<VisaApplicationModelForApplicant>>(StatusCodes.Status200OK)]
|
[ProducesResponseType<List<VisaApplicationPreview>>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
|||||||
@@ -854,7 +854,7 @@ namespace VisaApiClient
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>Success</returns>
|
/// <returns>Success</returns>
|
||||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationModelForAuthority>> GetPendingAsync()
|
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetPendingAsync()
|
||||||
{
|
{
|
||||||
return GetPendingAsync(System.Threading.CancellationToken.None);
|
return GetPendingAsync(System.Threading.CancellationToken.None);
|
||||||
}
|
}
|
||||||
@@ -868,7 +868,7 @@ namespace VisaApiClient
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>Success</returns>
|
/// <returns>Success</returns>
|
||||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationModelForAuthority>> GetPendingAsync(System.Threading.CancellationToken cancellationToken)
|
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetPendingAsync(System.Threading.CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var client_ = _httpClient;
|
var client_ = _httpClient;
|
||||||
var disposeClient_ = false;
|
var disposeClient_ = false;
|
||||||
@@ -909,7 +909,7 @@ namespace VisaApiClient
|
|||||||
var status_ = (int)response_.StatusCode;
|
var status_ = (int)response_.StatusCode;
|
||||||
if (status_ == 200)
|
if (status_ == 200)
|
||||||
{
|
{
|
||||||
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<VisaApplicationModelForAuthority>>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<VisaApplicationPreview>>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
if (objectResponse_.Object == null)
|
if (objectResponse_.Object == null)
|
||||||
{
|
{
|
||||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
@@ -956,6 +956,254 @@ namespace VisaApiClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns application
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accessible only for approving authorities
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Success</returns>
|
||||||
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
|
public virtual System.Threading.Tasks.Task<VisaApplicationModel> GetApplicationForAuthorityAsync(System.Guid applicationId)
|
||||||
|
{
|
||||||
|
return GetApplicationForAuthorityAsync(applicationId, System.Threading.CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||||
|
/// <summary>
|
||||||
|
/// Returns application
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accessible only for approving authorities
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Success</returns>
|
||||||
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
|
public virtual async System.Threading.Tasks.Task<VisaApplicationModel> GetApplicationForAuthorityAsync(System.Guid applicationId, System.Threading.CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (applicationId == null)
|
||||||
|
throw new System.ArgumentNullException("applicationId");
|
||||||
|
|
||||||
|
var client_ = _httpClient;
|
||||||
|
var disposeClient_ = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
request_.Method = new System.Net.Http.HttpMethod("GET");
|
||||||
|
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));
|
||||||
|
|
||||||
|
var urlBuilder_ = new System.Text.StringBuilder();
|
||||||
|
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
|
||||||
|
// Operation Path: "forAuthority/{applicationId}"
|
||||||
|
urlBuilder_.Append("forAuthority/");
|
||||||
|
urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(applicationId, System.Globalization.CultureInfo.InvariantCulture)));
|
||||||
|
|
||||||
|
await PrepareRequestAsync(client_, request_, urlBuilder_, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var url_ = urlBuilder_.ToString();
|
||||||
|
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
|
||||||
|
|
||||||
|
await PrepareRequestAsync(client_, request_, url_, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
||||||
|
var disposeResponse_ = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
|
||||||
|
foreach (var item_ in response_.Headers)
|
||||||
|
headers_[item_.Key] = item_.Value;
|
||||||
|
if (response_.Content != null && response_.Content.Headers != null)
|
||||||
|
{
|
||||||
|
foreach (var item_ in response_.Content.Headers)
|
||||||
|
headers_[item_.Key] = item_.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ProcessResponseAsync(client_, response_, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var status_ = (int)response_.StatusCode;
|
||||||
|
if (status_ == 200)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<VisaApplicationModel>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
return objectResponse_.Object;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (status_ == 401)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
throw new ApiException<ProblemDetails>("Unauthorized", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (status_ == 403)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (status_ == 404)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
throw new ApiException<ProblemDetails>("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (disposeResponse_)
|
||||||
|
response_.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (disposeClient_)
|
||||||
|
client_.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns application
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accessible only for applicant
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Success</returns>
|
||||||
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
|
public virtual System.Threading.Tasks.Task<VisaApplicationModel> GetApplicationForApplicantAsync(System.Guid applicationId)
|
||||||
|
{
|
||||||
|
return GetApplicationForApplicantAsync(applicationId, System.Threading.CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||||
|
/// <summary>
|
||||||
|
/// Returns application
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accessible only for applicant
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Success</returns>
|
||||||
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
|
public virtual async System.Threading.Tasks.Task<VisaApplicationModel> GetApplicationForApplicantAsync(System.Guid applicationId, System.Threading.CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (applicationId == null)
|
||||||
|
throw new System.ArgumentNullException("applicationId");
|
||||||
|
|
||||||
|
var client_ = _httpClient;
|
||||||
|
var disposeClient_ = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
request_.Method = new System.Net.Http.HttpMethod("GET");
|
||||||
|
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));
|
||||||
|
|
||||||
|
var urlBuilder_ = new System.Text.StringBuilder();
|
||||||
|
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
|
||||||
|
// Operation Path: "forApplicant/{applicationId}"
|
||||||
|
urlBuilder_.Append("forApplicant/");
|
||||||
|
urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(applicationId, System.Globalization.CultureInfo.InvariantCulture)));
|
||||||
|
|
||||||
|
await PrepareRequestAsync(client_, request_, urlBuilder_, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var url_ = urlBuilder_.ToString();
|
||||||
|
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
|
||||||
|
|
||||||
|
await PrepareRequestAsync(client_, request_, url_, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
||||||
|
var disposeResponse_ = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
|
||||||
|
foreach (var item_ in response_.Headers)
|
||||||
|
headers_[item_.Key] = item_.Value;
|
||||||
|
if (response_.Content != null && response_.Content.Headers != null)
|
||||||
|
{
|
||||||
|
foreach (var item_ in response_.Content.Headers)
|
||||||
|
headers_[item_.Key] = item_.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ProcessResponseAsync(client_, response_, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var status_ = (int)response_.StatusCode;
|
||||||
|
if (status_ == 200)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<VisaApplicationModel>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
return objectResponse_.Object;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (status_ == 401)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
throw new ApiException<ProblemDetails>("Unauthorized", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (status_ == 403)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (status_ == 404)
|
||||||
|
{
|
||||||
|
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (objectResponse_.Object == null)
|
||||||
|
{
|
||||||
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
|
}
|
||||||
|
throw new ApiException<ProblemDetails>("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (disposeResponse_)
|
||||||
|
response_.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (disposeClient_)
|
||||||
|
client_.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns all applications of one applicant
|
/// Returns all applications of one applicant
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -964,7 +1212,7 @@ namespace VisaApiClient
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>Success</returns>
|
/// <returns>Success</returns>
|
||||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationModelForApplicant>> GetForApplicantAsync()
|
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetForApplicantAsync()
|
||||||
{
|
{
|
||||||
return GetForApplicantAsync(System.Threading.CancellationToken.None);
|
return GetForApplicantAsync(System.Threading.CancellationToken.None);
|
||||||
}
|
}
|
||||||
@@ -978,7 +1226,7 @@ namespace VisaApiClient
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>Success</returns>
|
/// <returns>Success</returns>
|
||||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||||
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationModelForApplicant>> GetForApplicantAsync(System.Threading.CancellationToken cancellationToken)
|
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetForApplicantAsync(System.Threading.CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var client_ = _httpClient;
|
var client_ = _httpClient;
|
||||||
var disposeClient_ = false;
|
var disposeClient_ = false;
|
||||||
@@ -1019,7 +1267,7 @@ namespace VisaApiClient
|
|||||||
var status_ = (int)response_.StatusCode;
|
var status_ = (int)response_.StatusCode;
|
||||||
if (status_ == 200)
|
if (status_ == 200)
|
||||||
{
|
{
|
||||||
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<VisaApplicationModelForApplicant>>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<VisaApplicationPreview>>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||||
if (objectResponse_.Object == null)
|
if (objectResponse_.Object == null)
|
||||||
{
|
{
|
||||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||||
@@ -2055,12 +2303,16 @@ namespace VisaApiClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||||
public partial class VisaApplicationModelForApplicant
|
public partial class VisaApplicationModel
|
||||||
{
|
{
|
||||||
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||||
public System.Guid Id { get; set; } = default!;
|
public System.Guid Id { get; set; } = default!;
|
||||||
|
|
||||||
|
[Newtonsoft.Json.JsonProperty("applicant", Required = Newtonsoft.Json.Required.Always)]
|
||||||
|
[System.ComponentModel.DataAnnotations.Required]
|
||||||
|
public ApplicantModel Applicant { get; set; } = new ApplicantModel();
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
@@ -2107,52 +2359,26 @@ namespace VisaApiClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||||
public partial class VisaApplicationModelForAuthority
|
public partial class VisaApplicationPreview
|
||||||
{
|
{
|
||||||
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||||
public System.Guid Id { get; set; } = default!;
|
public System.Guid Id { get; set; } = default!;
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("applicant", Required = Newtonsoft.Json.Required.Always)]
|
|
||||||
[System.ComponentModel.DataAnnotations.Required]
|
|
||||||
public ApplicantModel Applicant { get; set; } = new ApplicantModel();
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
public ApplicationStatus Status { get; set; } = default!;
|
public ApplicationStatus Status { get; set; } = default!;
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
|
|
||||||
public ReentryPermitModel? ReentryPermit { get; set; } = default!;
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required]
|
[System.ComponentModel.DataAnnotations.Required]
|
||||||
public string DestinationCountry { get; set; } = default!;
|
public string DestinationCountry { get; set; } = default!;
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Always)]
|
|
||||||
[System.ComponentModel.DataAnnotations.Required]
|
|
||||||
public System.Collections.Generic.ICollection<PastVisaModel> PastVisas { get; set; } = new System.Collections.ObjectModel.Collection<PastVisaModel>();
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("permissionToDestCountry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
|
|
||||||
public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } = default!;
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Always)]
|
|
||||||
[System.ComponentModel.DataAnnotations.Required]
|
|
||||||
public System.Collections.Generic.ICollection<PastVisitModel> PastVisits { get; set; } = new System.Collections.ObjectModel.Collection<PastVisitModel>();
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("visaCategory", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("visaCategory", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
public VisaCategory VisaCategory { get; set; } = default!;
|
public VisaCategory VisaCategory { get; set; } = default!;
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("forGroup", Required = Newtonsoft.Json.Required.Always)]
|
|
||||||
public bool ForGroup { get; set; } = default!;
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("requestedNumberOfEntries", Required = Newtonsoft.Json.Required.Always)]
|
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
|
||||||
public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } = default!;
|
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("requestDate", Required = Newtonsoft.Json.Required.Always)]
|
[Newtonsoft.Json.JsonProperty("requestDate", Required = Newtonsoft.Json.Required.Always)]
|
||||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||||
public System.DateTimeOffset RequestDate { get; set; } = default!;
|
public System.DateTimeOffset RequestDate { get; set; } = default!;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user