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;
@@ -6,38 +7,48 @@ namespace ApplicationLayer.Services.VisaApplications.Models;
public class VisaApplicationModelForApplicant
{
/// <inheritdoc cref="VisaApplication.Id" />
[Required]
public Guid Id { get; set; }
/// <inheritdoc cref="VisaApplication.Status" />
[Required]
public ApplicationStatus Status { get; set; }
/// <inheritdoc cref="VisaApplication.ReentryPermit" />
public ReentryPermitModel? ReentryPermit { get; set; }
/// <inheritdoc cref="VisaApplication.DestinationCountry" />
[Required]
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" />
[Required]
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" />
[Required]
public DateTime RequestDate { get; set; }
/// <inheritdoc cref="VisaApplication.ValidDaysRequested" />
[Required]
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;
namespace ApplicationLayer.Services.VisaApplications.Models;
@@ -7,40 +8,51 @@ namespace ApplicationLayer.Services.VisaApplications.Models;
public class VisaApplicationModelForAuthority
{
/// <inheritdoc cref="VisaApplication.Id" />
[Required]
public Guid Id { get; set; }
/// Applicant of application
[Required]
public ApplicantModel Applicant { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.Status" />
[Required]
public ApplicationStatus Status { get; set; }
/// <inheritdoc cref="VisaApplication.ReentryPermit" />
public ReentryPermitModel? ReentryPermit { get; set; }
/// <inheritdoc cref="VisaApplication.DestinationCountry" />
[Required]
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; }
[Required]
public List<PastVisitModel> PastVisits { get; set; } = null!;
/// <inheritdoc cref="VisaApplication.VisaCategory" />
[Required]
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" />
[Required]
public DateTime RequestDate { get; set; }
/// <inheritdoc cref="VisaApplication.ValidDaysRequested" />
[Required]
public int ValidDaysRequested { get; set; }
}

View File

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

View File

@@ -1,17 +1,30 @@
@page "/applications"
@using System.Net
@using System.Text
@using BlazorWebAssemblyVisaApiClient.Components.Auth
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using VisaApiClient
@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 {
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()
{
@@ -19,35 +32,42 @@
try
{
switch (AuthComponent.CurrentRole)
{
case "Applicant":
var applications = await Client.GetForApplicantAsync();
switch (UserDataProvider.GetCurrentRole())
{
case "Applicant":
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)
{
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>");
}
foreach (var application in applications)
{
var rowClass = application.Status switch
{
ApplicationStatus.Pending => "",
ApplicationStatus.Approved => "table-success",
ApplicationStatus.Rejected => "table-danger",
ApplicationStatus.Closed => "table-danger",
_ => throw new ArgumentOutOfRangeException()
};
stringBuilder.AppendLine("</table >");
htmlMarkup = stringBuilder.ToString();
break;
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>");
}
htmlBody = stringBuilder.ToString();
break;
default:
htmlMarkup = AuthComponent.CurrentRole;
break;
}
Nav.NavigateTo("/"); //todo feedback
break;
}
}
catch (Exception e)
{
if (e is ApiException<ProblemDetails> { Result.Status: (int)HttpStatusCode.Unauthorized } problemDetailsException)
{
htmlMarkup = problemDetailsException.Result.Detail!;
htmlBody = $"<p>{problemDetailsException.Result.Detail!}</p>";
}
else
{
//ErrorHandler.Handle(e);
throw;
ErrorHandler.Handle(e);
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Reflection;
using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider;
using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider;
using FluentValidation;
using Microsoft.AspNetCore.Components.Web;
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.AddSingleton<IDateTimeProvider, DateTimeProvider>();
builder.Services.AddScoped<IUserDataProvider, UserDataProvider>();
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());
builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());

View File

@@ -29,6 +29,6 @@ public class TokenGenerator(TokenGeneratorOptions options, JwtSecurityTokenHandl
signingCredentials: options.Credentials,
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))")]
public partial class ApplicantModel
{
[Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel Name { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel? Name { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("passport", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PassportModel Passport { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("passport", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PassportModel? Passport { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("birthDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset BirthDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("birthDate", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset? BirthDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("countryOfBirth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
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)]
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))]
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))]
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)]
public NameModel FatherName { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("fatherName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel? FatherName { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("motherName", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel MotherName { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("motherName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public NameModel? MotherName { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("jobTitle", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? JobTitle { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("placeOfWork", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PlaceOfWorkModel PlaceOfWork { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("placeOfWork", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PlaceOfWorkModel? PlaceOfWork { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("isNonResident", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool IsNonResident { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("isNonResident", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
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))")]
public partial class AuthToken
{
[Newtonsoft.Json.JsonProperty("token", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? Token { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("token", Required = Newtonsoft.Json.Required.Always)]
[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))")]
public partial class PermissionToDestCountryModel
{
[Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset ExpirationDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset? ExpirationDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("issuer", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.ComponentModel.DataAnnotations.StringLength(200)]
@@ -1777,8 +1778,8 @@ namespace VisaApiClient
[System.ComponentModel.DataAnnotations.StringLength(25)]
public string? Number { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.DateTimeOffset ExpirationDate { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("expirationDate", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
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))")]
public partial class VisaApplicationCreateRequest
{
[Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ReentryPermitModel ReentryPermit { 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)]
[System.ComponentModel.DataAnnotations.Required]
@@ -1923,8 +1924,8 @@ namespace VisaApiClient
[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)]
public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = default!;
[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]
@@ -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))")]
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!;
[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))]
public ApplicationStatus Status { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ReentryPermitModel ReentryPermit { 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.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? DestinationCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required]
public string DestinationCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<PastVisaModel>? PastVisas { 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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = default!;
[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.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<PastVisitModel>? PastVisits { 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.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))]
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!;
[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))]
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!;
[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!;
}
@@ -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))")]
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!;
[Newtonsoft.Json.JsonProperty("applicant", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ApplicantModel Applicant { 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.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))]
public ApplicationStatus Status { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("reentryPermit", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public ReentryPermitModel ReentryPermit { 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.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? DestinationCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("destinationCountry", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required]
public string DestinationCountry { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("pastVisas", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<PastVisaModel>? PastVisas { 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.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = default!;
[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.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<PastVisitModel>? PastVisits { 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.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))]
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!;
[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))]
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!;
[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!;
}

View File

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

File diff suppressed because one or more lines are too long