86 lines
3.2 KiB
Plaintext
86 lines
3.2 KiB
Plaintext
@using SZUAbsolventenverein.Module.EventRegistration.Services
|
|
@using SZUAbsolventenverein.Module.EventRegistration.Models
|
|
|
|
@namespace SZUAbsolventenverein.Module.EventRegistration
|
|
@inherits ModuleBase
|
|
@inject IEventRegistrationService EventRegistrationService
|
|
@inject NavigationManager NavigationManager
|
|
@inject IStringLocalizer<Index> Localizer
|
|
|
|
@if (_EventRegistrations == null)
|
|
{
|
|
<p><em>Loading...</em></p>
|
|
}
|
|
else
|
|
{
|
|
<ActionLink Action="Add" Security="SecurityAccessLevel.Edit" Text="Add Event" ResourceKey="Add" />
|
|
<br />
|
|
<br />
|
|
<p>@Status</p>
|
|
@if (@_EventRegistrations.Count != 0)
|
|
{
|
|
<Pager Items="@_EventRegistrations">
|
|
<Header>
|
|
<th style="width: 1px;"> </th>
|
|
<th style="width: 1px;"> </th>
|
|
<th>@Localizer["Name"]</th>
|
|
<th>@Localizer["Date"]</th>
|
|
<th>@Localizer["Locataion"]</th>
|
|
<th style="width: 1px;"> </th>
|
|
</Header>
|
|
<Row>
|
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.EventId.ToString())" ResourceKey="Edit" /></td>
|
|
<td><ActionDialog Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" ResourceKey="Delete" Id="@context.EventId.ToString()" /></td>
|
|
<td>@context.Name</td>
|
|
<td>@context.EventDate.ToLocalTime()</td>
|
|
<td>@context.Location</td>
|
|
<td><ActionLink Action="Details" Parameters="@($"id=" + context.EventId.ToString())" ResourceKey="Details"/></td>
|
|
</Row>
|
|
</Pager>
|
|
}
|
|
else
|
|
{
|
|
<p>@Localizer["Message.DisplayNone"]</p>
|
|
}
|
|
}
|
|
|
|
@code {
|
|
private string Status;
|
|
|
|
public override List<Resource> Resources => new List<Resource>()
|
|
{
|
|
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" },
|
|
new Resource { ResourceType = ResourceType.Script, Url = ModulePath() + "Module.js" }
|
|
};
|
|
|
|
List<Event> _EventRegistrations;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
_EventRegistrations = await EventRegistrationService.GetEventsAsync(ModuleState.ModuleId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading EventRegistration {Error}", ex.Message);
|
|
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async Task Delete(Event EventRegistration)
|
|
{
|
|
try
|
|
{
|
|
await EventRegistrationService.DeleteEventAsync(EventRegistration.EventId, ModuleState.ModuleId);
|
|
await logger.LogInformation("EventRegistration Deleted {EventRegistration}", EventRegistration);
|
|
_EventRegistrations = await EventRegistrationService.GetEventsAsync(ModuleState.ModuleId);
|
|
StateHasChanged();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Deleting EventRegistration {EventRegistration} {Error}", EventRegistration, ex.Message);
|
|
AddModuleMessage(Localizer["Message.DeleteError"], MessageType.Error);
|
|
}
|
|
}
|
|
} |