Вытащил солюшен на уровень выше, чтобы прощё было дотнетить
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-10-05 14:32:06 +03:00
parent fa87a56ad1
commit aae4b28089
242 changed files with 159 additions and 159 deletions

View File

@@ -1,17 +1,17 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers; namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers;
public static class EnumExtensions public static class EnumExtensions
{ {
public static string GetDisplayName(this Enum value) public static string GetDisplayName(this Enum value)
{ {
var enumMembers = value.GetType().GetMembers(); var enumMembers = value.GetType().GetMembers();
var member = enumMembers.First(info => info.Name == value.ToString()); var member = enumMembers.First(info => info.Name == value.ToString());
var displayAttribute = (DisplayAttribute?)member var displayAttribute = (DisplayAttribute?)member
.GetCustomAttributes(typeof(DisplayAttribute), false) .GetCustomAttributes(typeof(DisplayAttribute), false)
.FirstOrDefault(); .FirstOrDefault();
var displayName = displayAttribute?.Name ?? value.ToString(); var displayName = displayAttribute?.Name ?? value.ToString();
return displayName; return displayName;
} }
} }

View File

@@ -1,143 +1,143 @@
@page "/applications" @page "/applications"
@using BlazorWebAssemblyVisaApiClient.Common.Exceptions @using BlazorWebAssemblyVisaApiClient.Common.Exceptions
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models @using BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models
@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-hover"> <table class="table table-bordered table-hover">
<thead> <thead>
<tr> <tr>
<th>Destination Country</th> <th>Destination Country</th>
<th>Visa Category</th> <th>Visa Category</th>
<th>Request date</th> <th>Request date</th>
<th>Days requested</th> <th>Days requested</th>
<th>Status</th> <th>Status</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var application in applications) @foreach (var application in applications)
{ {
var rowClass = application.Status switch var rowClass = application.Status switch
{ {
ApplicationStatus.Pending => "", ApplicationStatus.Pending => "",
ApplicationStatus.Approved => "table-success", ApplicationStatus.Approved => "table-success",
ApplicationStatus.Rejected => "table-danger", ApplicationStatus.Rejected => "table-danger",
ApplicationStatus.Closed => "table-danger", ApplicationStatus.Closed => "table-danger",
_ => throw new ArgumentOutOfRangeException() _ => throw new ArgumentOutOfRangeException()
}; };
<tr class="@rowClass"> <tr class="@rowClass">
<td>@application.DestinationCountry</td> <td>@application.DestinationCountry</td>
<td>@(((VisaCategoryModel)application.VisaCategory).GetDisplayName())</td> <td>@(((VisaCategoryModel)application.VisaCategory).GetDisplayName())</td>
<td>@application.RequestDate.ToString("d")</td> <td>@application.RequestDate.ToString("d")</td>
<td>@application.ValidDaysRequested</td> <td>@application.ValidDaysRequested</td>
<td>@application.Status.GetDisplayName()</td> <td>@application.Status.GetDisplayName()</td>
<td> <td>
<NavLink href="@($"/applications/{application.Id}")"> <NavLink href="@($"/applications/{application.Id}")">
<button class="btn-primary">See</button> <button class="btn-primary">See</button>
</NavLink> </NavLink>
@if (currentRole == Constants.ApplicantRole) @if (currentRole == Constants.ApplicantRole)
{ {
<span> | </span> <span> | </span>
<input type="button" class="btn-outline-primary" @onclick="() => DownloadApplication(application)" value="Download"/> <input type="button" class="btn-outline-primary" @onclick="() => DownloadApplication(application)" value="Download"/>
if (application.Status is ApplicationStatus.Pending) if (application.Status is ApplicationStatus.Pending)
{ {
<span> | </span> <span> | </span>
<input type="button" class="border-danger" @onclick="() => CloseApplication(application)" value="Close"/> <input type="button" class="border-danger" @onclick="() => CloseApplication(application)" value="Close"/>
} }
} }
</td> </td>
</tr> </tr>
} }
</tbody> </tbody>
</table > </table >
<script> <script>
window.downloadFileFromStream = async (contentStreamReference) => { window.downloadFileFromStream = async (contentStreamReference) => {
const arrayBuffer = await contentStreamReference.arrayBuffer(); const arrayBuffer = await contentStreamReference.arrayBuffer();
const blob = new Blob([arrayBuffer]); const blob = new Blob([arrayBuffer]);
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const anchorElement = document.createElement('a'); const anchorElement = document.createElement('a');
anchorElement.href = url; anchorElement.href = url;
anchorElement.download = 'Application.xlsx'; anchorElement.download = 'Application.xlsx';
anchorElement.click(); anchorElement.click();
anchorElement.remove(); anchorElement.remove();
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
} }
</script> </script>
@code { @code {
private string currentRole = null!; private string currentRole = null!;
private List<VisaApplicationPreview> applications = []; private List<VisaApplicationPreview> applications = [];
[Inject] private IUserDataProvider UserDataProvider { get; set; } = null!; [Inject] private IUserDataProvider UserDataProvider { get; set; } = null!;
[Inject] private IJSRuntime JavaScriptInterop { get; set; } = null!; [Inject] private IJSRuntime JavaScriptInterop { get; set; } = null!;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
currentRole = UserDataProvider.CurrentRole ?? throw new NotLoggedInException(); currentRole = UserDataProvider.CurrentRole ?? throw new NotLoggedInException();
} }
catch (Exception e) catch (Exception e)
{ {
ErrorHandler.Handle(e); ErrorHandler.Handle(e);
} }
await Fetch(); await Fetch();
} }
private async Task Fetch() private async Task Fetch()
{ {
try try
{ {
applications = currentRole switch applications = currentRole switch
{ {
Constants.ApplicantRole => (await Client.GetApplicationsForApplicantAsync()).OrderByDescending(a => a.RequestDate).ToList(), Constants.ApplicantRole => (await Client.GetApplicationsForApplicantAsync()).OrderByDescending(a => a.RequestDate).ToList(),
Constants.ApprovingAuthorityRole => (await Client.GetPendingAsync()).OrderByDescending(a => a.RequestDate).ToList(), Constants.ApprovingAuthorityRole => (await Client.GetPendingAsync()).OrderByDescending(a => a.RequestDate).ToList(),
_ => throw new NotLoggedInException() _ => throw new NotLoggedInException()
}; };
} }
catch (Exception e) catch (Exception e)
{ {
ErrorHandler.Handle(e); ErrorHandler.Handle(e);
} }
} }
private async Task CloseApplication(VisaApplicationPreview application) private async Task CloseApplication(VisaApplicationPreview application)
{ {
try try
{ {
await Client.CloseApplicationAsync(application.Id); await Client.CloseApplicationAsync(application.Id);
application.Status = ApplicationStatus.Closed; application.Status = ApplicationStatus.Closed;
StateHasChanged(); StateHasChanged();
} }
catch (Exception e) catch (Exception e)
{ {
ErrorHandler.Handle(e); ErrorHandler.Handle(e);
} }
} }
private async Task DownloadApplication(VisaApplicationPreview application) private async Task DownloadApplication(VisaApplicationPreview application)
{ {
try try
{ {
var response = await Client.DownloadApplicationForApplicantAsync(application.Id); var response = await Client.DownloadApplicationForApplicantAsync(application.Id);
using var streamRef = new DotNetStreamReference(stream: response.Stream); using var streamRef = new DotNetStreamReference(stream: response.Stream);
await JavaScriptInterop.InvokeVoidAsync("downloadFileFromStream", streamRef); await JavaScriptInterop.InvokeVoidAsync("downloadFileFromStream", streamRef);
} }
catch (Exception e) catch (Exception e)
{ {
ErrorHandler.Handle(e); ErrorHandler.Handle(e);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More