Applications.razor for applicants

This commit is contained in:
2024-09-06 21:37:16 +03:00
parent 53d5758527
commit f90a0e7e82
13 changed files with 227 additions and 125 deletions

View File

@@ -1,4 +1,9 @@
namespace ApplicationLayer.Services.AuthServices.Common using System.ComponentModel.DataAnnotations;
namespace ApplicationLayer.Services.AuthServices.Common
{ {
public record AuthToken(string Token); public class AuthToken
{
[Required] public string Token { get; set; } = null!;
}
} }

View File

@@ -1,4 +1,5 @@
using Domains.VisaApplicationDomain; using System.ComponentModel.DataAnnotations;
using Domains.VisaApplicationDomain;
namespace ApplicationLayer.Services.VisaApplications.Models; namespace ApplicationLayer.Services.VisaApplications.Models;
@@ -6,38 +7,48 @@ namespace ApplicationLayer.Services.VisaApplications.Models;
public class VisaApplicationModelForApplicant public class VisaApplicationModelForApplicant
{ {
/// <inheritdoc cref="VisaApplication.Id" /> /// <inheritdoc cref="VisaApplication.Id" />
[Required]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <inheritdoc cref="VisaApplication.Status" /> /// <inheritdoc cref="VisaApplication.Status" />
[Required]
public ApplicationStatus Status { get; set; } public ApplicationStatus Status { get; set; }
/// <inheritdoc cref="VisaApplication.ReentryPermit" /> /// <inheritdoc cref="VisaApplication.ReentryPermit" />
public ReentryPermitModel? ReentryPermit { get; set; } public ReentryPermitModel? ReentryPermit { get; set; }
/// <inheritdoc cref="VisaApplication.DestinationCountry" /> /// <inheritdoc cref="VisaApplication.DestinationCountry" />
[Required]
public string DestinationCountry { get; set; } = null!; public string DestinationCountry { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.PastVisas" /> /// <inheritdoc cref="VisaApplication.PastVisas" />
[Required]
public List<PastVisaModel> PastVisas { get; set; } = null!; public List<PastVisaModel> PastVisas { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.PermissionToDestCountry" /> /// <inheritdoc cref="VisaApplication.PermissionToDestCountry" />
public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } public PermissionToDestCountryModel? PermissionToDestCountry { get; set; }
/// <inheritdoc cref="VisaApplication.PastVisits" /> /// <inheritdoc cref="VisaApplication.PastVisits" />
[Required]
public List<PastVisitModel> PastVisits { get; set; } = null!; public List<PastVisitModel> PastVisits { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.VisaCategory" /> /// <inheritdoc cref="VisaApplication.VisaCategory" />
[Required]
public VisaCategory VisaCategory { get; set; } public VisaCategory VisaCategory { get; set; }
/// <inheritdoc cref="VisaApplication.ForGroup" /> /// <inheritdoc cref="VisaApplication.ForGroup" />
[Required]
public bool ForGroup { get; set; } public bool ForGroup { get; set; }
/// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" /> /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" />
[Required]
public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; }
/// <inheritdoc cref="VisaApplication.RequestDate" /> /// <inheritdoc cref="VisaApplication.RequestDate" />
[Required]
public DateTime RequestDate { get; set; } public DateTime RequestDate { get; set; }
/// <inheritdoc cref="VisaApplication.ValidDaysRequested" /> /// <inheritdoc cref="VisaApplication.ValidDaysRequested" />
[Required]
public int ValidDaysRequested { get; set; } public int ValidDaysRequested { get; set; }
} }

View File

@@ -1,4 +1,5 @@
using ApplicationLayer.Services.Applicants.Models; using System.ComponentModel.DataAnnotations;
using ApplicationLayer.Services.Applicants.Models;
using Domains.VisaApplicationDomain; using Domains.VisaApplicationDomain;
namespace ApplicationLayer.Services.VisaApplications.Models; namespace ApplicationLayer.Services.VisaApplications.Models;
@@ -7,40 +8,51 @@ namespace ApplicationLayer.Services.VisaApplications.Models;
public class VisaApplicationModelForAuthority public class VisaApplicationModelForAuthority
{ {
/// <inheritdoc cref="VisaApplication.Id" /> /// <inheritdoc cref="VisaApplication.Id" />
[Required]
public Guid Id { get; set; } public Guid Id { get; set; }
/// Applicant of application /// Applicant of application
[Required]
public ApplicantModel Applicant { get; set; } = null!; public ApplicantModel Applicant { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.Status" /> /// <inheritdoc cref="VisaApplication.Status" />
[Required]
public ApplicationStatus Status { get; set; } public ApplicationStatus Status { get; set; }
/// <inheritdoc cref="VisaApplication.ReentryPermit" /> /// <inheritdoc cref="VisaApplication.ReentryPermit" />
public ReentryPermitModel? ReentryPermit { get; set; } public ReentryPermitModel? ReentryPermit { get; set; }
/// <inheritdoc cref="VisaApplication.DestinationCountry" /> /// <inheritdoc cref="VisaApplication.DestinationCountry" />
[Required]
public string DestinationCountry { get; set; } = null!; public string DestinationCountry { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.PastVisas" /> /// <inheritdoc cref="VisaApplication.PastVisas" />
[Required]
public List<PastVisaModel> PastVisas { get; set; } = null!; public List<PastVisaModel> PastVisas { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.PermissionToDestCountry" /> /// <inheritdoc cref="VisaApplication.PermissionToDestCountry" />
public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } public PermissionToDestCountryModel? PermissionToDestCountry { get; set; }
[Required]
public List<PastVisitModel> PastVisits { get; set; } = null!; public List<PastVisitModel> PastVisits { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.VisaCategory" /> /// <inheritdoc cref="VisaApplication.VisaCategory" />
[Required]
public VisaCategory VisaCategory { get; set; } public VisaCategory VisaCategory { get; set; }
/// <inheritdoc cref="VisaApplication.ForGroup" /> /// <inheritdoc cref="VisaApplication.ForGroup" />
[Required]
public bool ForGroup { get; set; } public bool ForGroup { get; set; }
/// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" /> /// <inheritdoc cref="VisaApplication.RequestedNumberOfEntries" />
[Required]
public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; }
/// <inheritdoc cref="VisaApplication.RequestDate" /> /// <inheritdoc cref="VisaApplication.RequestDate" />
[Required]
public DateTime RequestDate { get; set; } public DateTime RequestDate { get; set; }
/// <inheritdoc cref="VisaApplication.ValidDaysRequested" /> /// <inheritdoc cref="VisaApplication.ValidDaysRequested" />
[Required]
public int ValidDaysRequested { get; set; } public int ValidDaysRequested { get; set; }
} }

View File

@@ -1,16 +1,10 @@
@using System.Net @using System.Net
@using System.IdentityModel.Tokens.Jwt
@using System.Security.Claims
@using BlazorWebAssemblyVisaApiClient.Components.Auth.Exceptions
@using BlazorWebAssemblyVisaApiClient.ErrorHandling @using BlazorWebAssemblyVisaApiClient.ErrorHandling
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using VisaApiClient @using VisaApiClient
@code { @code {
public static bool LoggedIn; public static AuthData? AuthData;
public static ApplicantModel? CurrentApplicant; //todo api action
public static string? CurrentRole;
private static AuthData savedData = null!;
private static readonly JwtSecurityTokenHandler TokenHandler = new();
[CascadingParameter] private GlobalErrorHandler ErrorHandler { get; set; } = null!; [CascadingParameter] private GlobalErrorHandler ErrorHandler { get; set; } = null!;
@@ -20,6 +14,8 @@
[Inject] private NavigationManager Nav { get; set; } = null!; [Inject] private NavigationManager Nav { get; set; } = null!;
[Inject] private IUserDataProvider UserDataProvider { get; set; } = null!;
///Authorize with email and password ///Authorize with email and password
/// <returns>Message to user</returns> /// <returns>Message to user</returns>
public async Task TryAuthorize(AuthData authData) public async Task TryAuthorize(AuthData authData)
@@ -28,12 +24,8 @@
try try
{ {
var token = await Client.LoginAsync(authData.Email, authData.Password); var token = await Client.LoginAsync(authData.Email, authData.Password);
Client.SetAuthToken(token); Client.AuthToken = token;
CurrentRole = TokenHandler.ReadJwtToken(token.Token) AuthData = authData;
.Claims
.FirstOrDefault(claim => claim.Type == ClaimTypes.Role)?
.Value;
savedData = authData;
Status?.SetSucces("Logged in successfully."); Status?.SetSucces("Logged in successfully.");
} }
@@ -57,20 +49,18 @@
} }
///Re-auth if token expired or something ///Re-auth if token expired or something
public async Task ReAuthenticate(bool redirectOnFailure = true) public async Task ReAuthenticate()
{ {
if (!LoggedIn) if (AuthData is not null)
{ {
if (redirectOnFailure) await TryAuthorize(AuthData);
{ }
Nav.NavigateTo("/"); else
return; {
} Client.AuthToken = null;
AuthData = null;
throw new NotLoggedInException(); Nav.NavigateTo("/");
} }
await TryAuthorize(savedData);
} }
} }

View File

@@ -0,0 +1,12 @@
using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
{
public interface IUserDataProvider
{
public ApplicantModel? GetApplicant();
public string? GetCurrentRole();
}
}

View File

@@ -0,0 +1,30 @@
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
{
public class UserDataProvider(Client client) : IUserDataProvider
{
private static readonly JwtSecurityTokenHandler tokenHandler = new ();
public ApplicantModel? GetApplicant()
{
//todo api action
return null;
}
public string? GetCurrentRole()
{
if (client.AuthToken is null)
{
return null;
}
var token = tokenHandler.ReadJwtToken(client.AuthToken.Token);
var role = token.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Role)?.Value;
return role;
}
}
}

View File

@@ -15,6 +15,13 @@
</NavLink> </NavLink>
</div> </div>
</nav> </nav>
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="applications" Match="NavLinkMatch.All">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Applications
</NavLink>
</div>
</nav>
</div> </div>
@code { @code {

View File

@@ -1,17 +1,30 @@
@page "/applications" @page "/applications"
@using System.Net @using System.Net
@using System.Text @using System.Text
@using BlazorWebAssemblyVisaApiClient.Components.Auth
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using VisaApiClient @using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase @inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
<PageTitle>@(AuthComponent.CurrentRole ?? "bruh")</PageTitle> <PageTitle>Applications</PageTitle>
@((MarkupString)htmlMarkup) <table class="table table-bordered">
<thead>
@((MarkupString)htmlHead)
</thead>
<tbody>
@((MarkupString)htmlBody)
</tbody>
</table >
@code { @code {
private string htmlMarkup = "bruh"; private string htmlBody = null!;
private string htmlHead = 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()
{ {
@@ -19,35 +32,42 @@
try try
{ {
switch (AuthComponent.CurrentRole) switch (UserDataProvider.GetCurrentRole())
{ {
case "Applicant": case "Applicant":
var applications = await Client.GetForApplicantAsync(); htmlHead = "<tr><th>Destination Country</th><th>Visa Category</th><th>Request date</th><th>Days requested</th><th>Status</th></tr>";
var applications = await Client.GetForApplicantAsync();
stringBuilder.AppendLine("<table><tr><th>Destination Country</th><th>Visa Category</th><th>Request date</th><th>Days requested</th><th>Status</th></tr>"); foreach (var application in applications)
foreach (var application in applications) {
{ var rowClass = application.Status switch
stringBuilder.AppendLine($"<tr><th>{application.DestinationCountry}</th><th>{application.VisaCategory.GetDisplayName()}</th><th>{application.RequestDate.ToString("d")}</th><th>{application.ValidDaysRequested}</th><th>{application.Status.GetDisplayName()}</th></tr>"); {
} ApplicationStatus.Pending => "",
ApplicationStatus.Approved => "table-success",
ApplicationStatus.Rejected => "table-danger",
ApplicationStatus.Closed => "table-danger",
_ => throw new ArgumentOutOfRangeException()
};
stringBuilder.AppendLine("</table >"); stringBuilder.AppendLine($"<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></tr>");
htmlMarkup = stringBuilder.ToString(); }
break;
htmlBody = stringBuilder.ToString();
break;
default: default:
htmlMarkup = AuthComponent.CurrentRole; Nav.NavigateTo("/"); //todo feedback
break; break;
} }
} }
catch (Exception e) catch (Exception e)
{ {
if (e is ApiException<ProblemDetails> { Result.Status: (int)HttpStatusCode.Unauthorized } problemDetailsException) if (e is ApiException<ProblemDetails> { Result.Status: (int)HttpStatusCode.Unauthorized } problemDetailsException)
{ {
htmlMarkup = problemDetailsException.Result.Detail!; htmlBody = $"<p>{problemDetailsException.Result.Detail!}</p>";
} }
else else
{ {
//ErrorHandler.Handle(e); ErrorHandler.Handle(e);
throw;
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using System.Reflection; using System.Reflection;
using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider; using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider;
using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider;
using FluentValidation; using FluentValidation;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
@@ -23,6 +24,7 @@ public class Program
builder.Services.AddScoped<Client>(sp => new Client(baseAddress, sp.GetRequiredService<HttpClient>())); builder.Services.AddScoped<Client>(sp => new Client(baseAddress, sp.GetRequiredService<HttpClient>()));
builder.Services.AddSingleton<IDateTimeProvider, DateTimeProvider>(); builder.Services.AddSingleton<IDateTimeProvider, DateTimeProvider>();
builder.Services.AddScoped<IUserDataProvider, UserDataProvider>();
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly()); builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());
builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());

View File

@@ -29,6 +29,6 @@ public class TokenGenerator(TokenGeneratorOptions options, JwtSecurityTokenHandl
signingCredentials: options.Credentials, signingCredentials: options.Credentials,
claims: claims); claims: claims);
return new AuthToken(tokenHandler.WriteToken(token)); return new AuthToken { Token = tokenHandler.WriteToken(token) };
} }
} }

View File

@@ -1494,14 +1494,14 @@ 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 ApplicantModel public partial class ApplicantModel
{ {
[Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel Name { get; set; } = default!; public NameModel? Name { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("passport", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("passport", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PassportModel Passport { get; set; } = default!; public PassportModel? Passport { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("birthDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("birthDate", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset BirthDate { get; set; } = default!; public System.DateTimeOffset? BirthDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("countryOfBirth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("countryOfBirth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? CountryOfBirth { get; set; } = default!; public string? CountryOfBirth { get; set; } = default!;
@@ -1515,28 +1515,28 @@ namespace VisaApiClient
[Newtonsoft.Json.JsonProperty("citizenshipByBirth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("citizenshipByBirth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? CitizenshipByBirth { get; set; } = default!; public string? CitizenshipByBirth { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("gender", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("gender", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public Gender Gender { get; set; } = default!; public Gender? Gender { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("maritalStatus", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("maritalStatus", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public MaritalStatus MaritalStatus { get; set; } = default!; public MaritalStatus? MaritalStatus { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("fatherName", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("fatherName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel FatherName { get; set; } = default!; public NameModel? FatherName { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("motherName", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("motherName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel MotherName { get; set; } = default!; public NameModel? MotherName { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("jobTitle", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("jobTitle", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? JobTitle { get; set; } = default!; public string? JobTitle { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("placeOfWork", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("placeOfWork", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PlaceOfWorkModel PlaceOfWork { get; set; } = default!; public PlaceOfWorkModel? PlaceOfWork { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("isNonResident", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("isNonResident", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool IsNonResident { get; set; } = default!; public bool? IsNonResident { get; set; } = default!;
} }
@@ -1576,8 +1576,9 @@ 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 AuthToken public partial class AuthToken
{ {
[Newtonsoft.Json.JsonProperty("token", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("token", Required = Newtonsoft.Json.Required.Always)]
public string? Token { get; set; } = default!; [System.ComponentModel.DataAnnotations.Required]
public string Token { get; set; } = default!;
} }
@@ -1713,8 +1714,8 @@ 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 PermissionToDestCountryModel public partial class PermissionToDestCountryModel
{ {
[Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset ExpirationDate { get; set; } = default!; public System.DateTimeOffset? ExpirationDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("issuer", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("issuer", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.ComponentModel.DataAnnotations.StringLength(200)] [System.ComponentModel.DataAnnotations.StringLength(200)]
@@ -1777,8 +1778,8 @@ namespace VisaApiClient
[System.ComponentModel.DataAnnotations.StringLength(25)] [System.ComponentModel.DataAnnotations.StringLength(25)]
public string? Number { get; set; } = default!; public string? Number { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset ExpirationDate { get; set; } = default!; public System.DateTimeOffset? ExpirationDate { get; set; } = default!;
} }
@@ -1894,8 +1895,8 @@ 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 VisaApplicationCreateRequest public partial class VisaApplicationCreateRequest
{ {
[Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ReentryPermitModel ReentryPermit { get; set; } = default!; 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]
@@ -1923,8 +1924,8 @@ namespace VisaApiClient
[System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.Required]
public System.Collections.Generic.ICollection<PastVisaModel> PastVisas { get; set; } = new System.Collections.ObjectModel.Collection<PastVisaModel>(); public System.Collections.Generic.ICollection<PastVisaModel> PastVisas { get; set; } = new System.Collections.ObjectModel.Collection<PastVisaModel>();
[Newtonsoft.Json.JsonProperty("permissionToDestCountry", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("permissionToDestCountry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = default!; public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Always)] [Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.Required]
@@ -1935,43 +1936,51 @@ 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 VisaApplicationModelForApplicant
{ {
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.Guid Id { get; set; } = default!; public System.Guid Id { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)]
[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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ReentryPermitModel ReentryPermit { get; set; } = default!; public ReentryPermitModel? ReentryPermit { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Always)]
public string? DestinationCountry { get; set; } = default!; [System.ComponentModel.DataAnnotations.Required]
public string DestinationCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Always)]
public System.Collections.Generic.ICollection<PastVisaModel>? PastVisas { get; set; } = default!; [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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("permissionToDestCountry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = default!; public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Always)]
public System.Collections.Generic.ICollection<PastVisitModel>? PastVisits { get; set; } = default!; [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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("visaCategory", Required = Newtonsoft.Json.Required.Always)]
[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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("forGroup", Required = Newtonsoft.Json.Required.Always)]
public bool ForGroup { get; set; } = default!; public bool ForGroup { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("requestedNumberOfEntries", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("requestedNumberOfEntries", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } = default!; public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("requestDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("requestDate", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.DateTimeOffset RequestDate { get; set; } = default!; public System.DateTimeOffset RequestDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("validDaysRequested", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("validDaysRequested", Required = Newtonsoft.Json.Required.Always)]
public int ValidDaysRequested { get; set; } = default!; public int ValidDaysRequested { get; set; } = default!;
} }
@@ -1979,46 +1988,55 @@ 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 VisaApplicationModelForAuthority
{ {
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
[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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("applicant", Required = Newtonsoft.Json.Required.Always)]
public ApplicantModel Applicant { get; set; } = default!; [System.ComponentModel.DataAnnotations.Required]
public ApplicantModel Applicant { get; set; } = new ApplicantModel();
[Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)]
[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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ReentryPermitModel ReentryPermit { get; set; } = default!; public ReentryPermitModel? ReentryPermit { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Always)]
public string? DestinationCountry { get; set; } = default!; [System.ComponentModel.DataAnnotations.Required]
public string DestinationCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Always)]
public System.Collections.Generic.ICollection<PastVisaModel>? PastVisas { get; set; } = default!; [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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("permissionToDestCountry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = default!; public PermissionToDestCountryModel? PermissionToDestCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("pastVisits", Required = Newtonsoft.Json.Required.Always)]
public System.Collections.Generic.ICollection<PastVisitModel>? PastVisits { get; set; } = default!; [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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("visaCategory", Required = Newtonsoft.Json.Required.Always)]
[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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("forGroup", Required = Newtonsoft.Json.Required.Always)]
public bool ForGroup { get; set; } = default!; public bool ForGroup { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("requestedNumberOfEntries", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("requestedNumberOfEntries", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } = default!; public RequestedNumberOfEntries RequestedNumberOfEntries { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("requestDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("requestDate", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.DateTimeOffset RequestDate { get; set; } = default!; public System.DateTimeOffset RequestDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("validDaysRequested", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonProperty("validDaysRequested", Required = Newtonsoft.Json.Required.Always)]
public int ValidDaysRequested { get; set; } = default!; public int ValidDaysRequested { get; set; } = default!;
} }

View File

@@ -4,12 +4,7 @@ namespace VisaApiClient
{ {
public class ClientBase public class ClientBase
{ {
protected AuthToken? AuthToken { get; private set; } public AuthToken? AuthToken { get; set; }
public void SetAuthToken(AuthToken token)
{
AuthToken = token;
}
protected Task<HttpRequestMessage> CreateHttpRequestMessageAsync(CancellationToken cancellationToken) protected Task<HttpRequestMessage> CreateHttpRequestMessageAsync(CancellationToken cancellationToken)
{ {

File diff suppressed because one or more lines are too long