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
This commit is contained in:
@ -8,22 +8,38 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IStringLocalizer<Edit> Localizer
|
||||
|
||||
<div class="container">
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="name" HelpText="Enter a name" ResourceKey="Name">Name: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input id="name" class="form-control" @bind="@_name" required />
|
||||
</div>
|
||||
|
||||
<h3>Anmeldung zum Event</h3>
|
||||
|
||||
<p>Willst du am Event (@_name) teilnehmen?</p>
|
||||
|
||||
@if (PageState.User != null) {
|
||||
|
||||
@if (Status != null)
|
||||
{
|
||||
<p class="mt-3"><strong>Status:</strong>
|
||||
@if (Status == true)
|
||||
{
|
||||
@Localizer["Zusage"]
|
||||
<button class="btn btn-danger" @onclick="Absage">@Localizer["Absagen"]</button>
|
||||
} else
|
||||
{
|
||||
@Localizer["Absage"]
|
||||
<button class="btn btn-success" @onclick="Zusage">@Localizer["Zusagen"]</button>
|
||||
}
|
||||
</p>
|
||||
} else {
|
||||
<div class="buttons">
|
||||
<button class="btn btn-success" @onclick="Zusage">@Localizer["Zusagen"]</button>
|
||||
<button class="btn btn-danger" @onclick="Absage">@Localizer["Absagen"]</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-success" @onclick="Save">@Localizer["Save"]</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
||||
<br /><br />
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
||||
}
|
||||
} else
|
||||
{
|
||||
<p class="mt-3">Um dich für dieses Event zu registrieren, muss man sich zuerst anmelden.</p> <Login />
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||
|
||||
public override string Actions => "Details";
|
||||
|
||||
@ -44,19 +60,59 @@
|
||||
private string _modifiedby;
|
||||
private DateTime _modifiedon;
|
||||
|
||||
private Response _response;
|
||||
private bool? Status;
|
||||
|
||||
private async Task SendResponse(bool response)
|
||||
{
|
||||
if(_response == null)
|
||||
{
|
||||
_response = new Response();
|
||||
_response.EventRegistrationId = _id;
|
||||
_response.OwnerId = PageState.User.UserId;
|
||||
_response.ModuleId = ModuleState.ModuleId;
|
||||
_response.ResponseType = response;
|
||||
_response = await EventRegistrationService.AddResponseAsync(_response);
|
||||
} else
|
||||
{
|
||||
_response.ResponseType = response;
|
||||
_response = await EventRegistrationService.UpdateResponseAsync(_response);
|
||||
}
|
||||
if(_response != null) Status = _response.ResponseType;
|
||||
}
|
||||
|
||||
private async void Zusage()
|
||||
{
|
||||
await SendResponse(true);
|
||||
}
|
||||
|
||||
private async void Absage()
|
||||
{
|
||||
await SendResponse(false);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||
Event EventRegistration = await EventRegistrationService.GetEventRegistrationAsync(_id, ModuleState.ModuleId);
|
||||
if (EventRegistration != null)
|
||||
|
||||
Event currentEvent;
|
||||
Response rsvp;
|
||||
(currentEvent, rsvp) = await EventRegistrationService.GetEventDetails(_id, ModuleState.ModuleId);
|
||||
if (currentEvent != null)
|
||||
{
|
||||
_name = EventRegistration.Name;
|
||||
_createdby = EventRegistration.CreatedBy;
|
||||
_createdon = EventRegistration.CreatedOn;
|
||||
_modifiedby = EventRegistration.ModifiedBy;
|
||||
_modifiedon = EventRegistration.ModifiedOn;
|
||||
_name = currentEvent.Name;
|
||||
_createdby = currentEvent.CreatedBy;
|
||||
_createdon = currentEvent.CreatedOn;
|
||||
_modifiedby = currentEvent.ModifiedBy;
|
||||
_modifiedon = currentEvent.ModifiedOn;
|
||||
}
|
||||
|
||||
if(rsvp != null)
|
||||
{
|
||||
_response = rsvp;
|
||||
Status = rsvp.ResponseType;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -79,14 +135,14 @@
|
||||
Event EventRegistration = new Event();
|
||||
EventRegistration.ModuleId = ModuleState.ModuleId;
|
||||
EventRegistration.Name = _name;
|
||||
EventRegistration = await EventRegistrationService.AddEventRegistrationAsync(EventRegistration);
|
||||
EventRegistration = await EventRegistrationService.AddEventAsync(EventRegistration);
|
||||
await logger.LogInformation("EventRegistration Added {EventRegistration}", EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
Event EventRegistration = await EventRegistrationService.GetEventRegistrationAsync(_id, ModuleState.ModuleId);
|
||||
Event EventRegistration = await EventRegistrationService.GetEventAsync(_id, ModuleState.ModuleId);
|
||||
EventRegistration.Name = _name;
|
||||
await EventRegistrationService.UpdateEventRegistrationAsync(EventRegistration);
|
||||
await EventRegistrationService.UpdateEventAsync(EventRegistration);
|
||||
await logger.LogInformation("EventRegistration Updated {EventRegistration}", EventRegistration);
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
|
Reference in New Issue
Block a user