Konstantin Hintermayer 38c5bef225 Bulk-Commit: Darft: Anmeldetool.
Interface Definition: done
Server-Side-Implementation: partly done (CR missing, potential Refactor, ...)
Client-Side-Implementation: started: (UI: done, Service: started, but works with SSR)
Missing: Permissions / Roles to restrict access to an event.
Missing: Fields on Event.
Missing: Good Styling
Time-Took: about 12 Hours.
Learning: Commit in smaller packets, rest will be discussed at CR
2025-05-14 20:40:10 +02:00

94 lines
3.4 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;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th>@Localizer["Name"]</th>
<th style="width: 1px;">&nbsp;</th>
</Header>
<Row>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.EventId.ToString())" ResourceKey="Edit" /></td>
<td><ActionDialog Header="Delete EventRegistration" Message="Are You Sure You Wish To Delete This EventRegistration?" 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><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);
}
}
private async Task Accept(Event eventRegistration)
{
Status = ("EventRegistration Accepted " + eventRegistration.Name);
await logger.LogInformation("EventRegistration Accepted {EventRegistration}", eventRegistration);
}
private void Reject()
{
Status = "EventRegistration Rejected 1";
}
}