Files
Module.AdminModules/Client/Modules/SZUAbsolventenverein.Module.ReportSystem/Index.razor

79 lines
2.6 KiB
Plaintext

@namespace SZUAbsolventenverein.Module.ReportSystem
@using Microsoft.VisualBasic.FileIO
@using SZUAbsolventenverein.Module.ReportSystem.Models
@using SZUAbsolventenverein.Module.ReportSystem.Services
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IReportSystemReportingService ReportingService
@inject IStringLocalizer<Index> Localizer
@if (reportings == null)
{
<p><em>Loading...</em></p>
}
else
{
<br />
<br />
@if (reportings.Count != 0)
{
<Pager Items="@reportings">
<Header>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th>@Localizer["Name"]</th>
</Header>
<Row>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Edit" /></td>
<td><ActionDialog Header="Delete AdminModules" Message="Are You Sure You Wish To Delete This AdminModules?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" ResourceKey="Delete" Id="@context.ReportingID.ToString()" /></td>
<td><ActionLink Action="Send" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Send" /></td>
<td>@context.Reason</td>
</Row>
</Pager>
}
else
{
<p>@Localizer["Message.DisplayNone"]</p>
}
}
@code {
public override string RenderMode => RenderModes.Interactive;
public override List<Resource> Resources => new List<Resource>()
{
new Stylesheet("_content/SZUAbsolventenverein.Module.ReportSystem/Module.css"),
new Script("_content/SZUAbsolventenverein.Module.ReportSystem/Module.js")
};
private List<Reporting> reportings = new List<Reporting>();
protected override async Task OnInitializedAsync()
{
try
{
reportings = await ReportingService.GetReportsAsync(ModuleState.ModuleId);
}
catch (Exception ex)
{
logger.LogError("Error fetching reportings: {Message}", ex.Message);
};
}
private async Task Delete(Reporting reporting)
{
try
{
await ReportingService.DeleteReportingAsync(reporting.ReportingID, ModuleState.ModuleId);
reportings.Remove(reporting);
StateHasChanged();
}
catch (Exception ex)
{
logger.LogError("Error deleting reporting: {Message}", ex.Message);
}
}
}