Files
Module.AdminModules/Client/Modules/SZUAbsolventenverein.Module.AdminMassMailing/Index.razor
2025-11-27 12:49:36 +01:00

81 lines
3.0 KiB
Plaintext

@using SZUAbsolventenverein.Module.AdminModules.Services
@using SZUAbsolventenverein.Module.AdminModules.Models
@namespace SZUAbsolventenverein.Module.AdminMassMailing
@inherits ModuleBase
@inject IAdminModulesService AdminModulesService
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Index> Localizer
@if (_AdminModuless == null)
{
<p><em>Loading...</em></p>
}
else
{
<ActionLink Action="Add" Security="SecurityAccessLevel.Edit" Text="Add AdminModules" ResourceKey="Add" />
<br />
<br />
@if (@_AdminModuless.Count != 0)
{
<Pager Items="@_AdminModuless">
<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.AdminModulesId.ToString())" 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.AdminModulesId.ToString()" /></td>
<td><ActionLink Action="Send" Parameters="@($"id=" + context.AdminModulesId.ToString())" ResourceKey="Send" /></td>
<td>@context.Name</td>
</Row>
</Pager>
}
else
{
<p>@Localizer["Message.DisplayNone"]</p>
}
}
@code {
public override string RenderMode => RenderModes.Static;
public override List<Resource> Resources => new List<Resource>()
{
new Stylesheet("_content/SZUAbsolventenverein.Module.AdminModules/Module.css"),
new Script("_content/SZUAbsolventenverein.Module.AdminModules/Module.js")
};
List<AdminModules> _AdminModuless;
protected override async Task OnInitializedAsync()
{
try
{
_AdminModuless = await AdminModulesService.GetAdminModulessAsync(ModuleState.ModuleId);
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading AdminModules {Error}", ex.Message);
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
}
}
private async Task Delete(AdminModules AdminModules)
{
try
{
await AdminModulesService.DeleteAdminModulesAsync(AdminModules.AdminModulesId, ModuleState.ModuleId);
await logger.LogInformation("AdminModules Deleted {AdminModules}", AdminModules);
_AdminModuless = await AdminModulesService.GetAdminModulessAsync(ModuleState.ModuleId);
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting AdminModules {AdminModules} {Error}", AdminModules, ex.Message);
AddModuleMessage(Localizer["Message.DeleteError"], MessageType.Error);
}
}
}