95 lines
3.5 KiB
Plaintext
95 lines
3.5 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 />
|
|
@if (@_EventRegistrations.Count != 0)
|
|
{
|
|
|
|
<div class="event-list">
|
|
<div class="event-list">
|
|
@foreach (var context in _EventRegistrations)
|
|
{
|
|
<div class="event-card">
|
|
<h3>@context.Name</h3>
|
|
<p><strong>@Localizer["Date"]:</strong> @context.EventDate.ToLocalTime()</p>
|
|
<p><strong>@Localizer["Location"]:</strong> @context.Location</p>
|
|
|
|
<div class="event-actions">
|
|
<ActionLink Action="Edit"
|
|
Parameters="@($"id={context.EventId}")"
|
|
ResourceKey="Edit" />
|
|
|
|
<ActionDialog Action="Delete"
|
|
Security="SecurityAccessLevel.Edit"
|
|
Class="btn btn-danger"
|
|
OnClick="@(async () => await Delete(context))"
|
|
ResourceKey="Delete"
|
|
Id="@context.EventId.ToString()" />
|
|
|
|
<ActionLink Action="Details"
|
|
Parameters="@($"id={context.EventId}")"
|
|
ResourceKey="Details" />
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<p>@Localizer["Message.DisplayNone"]</p>
|
|
}
|
|
}
|
|
|
|
@code {
|
|
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);
|
|
}
|
|
}
|
|
} |