@using Oqtane.Modules.Controls @using SZUAbsolventenverein.Module.EventRegistration.Services @using SZUAbsolventenverein.Module.EventRegistration.Models @namespace SZUAbsolventenverein.Module.EventRegistration @inherits ModuleBase @inject IEventRegistrationService EventRegistrationService @inject NavigationManager NavigationManager @inject IStringLocalizer Localizer

Anmeldung zum Event

Willst du am Event (@_name) teilnehmen?

@if (PageState.User != null) { @if (Status != null) {

Status: @if (Status == true) { @Localizer["Zusage"] } else { @Localizer["Absage"] }

} else {
} } else {

Um dich für dieses Event zu registrieren, muss man sich zuerst anmelden.

} @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; public override string Actions => "Details"; public override string Title => "Event Details"; public override List Resources => new List() { new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } }; private ElementReference form; private bool validated = false; private int _id; private string _name; private string _createdby; private DateTime _createdon; 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 currentEvent; Response rsvp; (currentEvent, rsvp) = await EventRegistrationService.GetEventDetails(_id, ModuleState.ModuleId); if (currentEvent != null) { _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) { await logger.LogError(ex, "Error Loading EventRegistration {EventRegistrationId} {Error}", _id, ex.Message); AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error); } } private async Task Save() { try { validated = true; var interop = new Oqtane.UI.Interop(JSRuntime); if (await interop.FormValid(form)) { if (PageState.Action == "Add") { Event EventRegistration = new Event(); EventRegistration.ModuleId = ModuleState.ModuleId; EventRegistration.Name = _name; EventRegistration = await EventRegistrationService.AddEventAsync(EventRegistration); await logger.LogInformation("EventRegistration Added {EventRegistration}", EventRegistration); } else { Event EventRegistration = await EventRegistrationService.GetEventAsync(_id, ModuleState.ModuleId); EventRegistration.Name = _name; await EventRegistrationService.UpdateEventAsync(EventRegistration); await logger.LogInformation("EventRegistration Updated {EventRegistration}", EventRegistration); } NavigationManager.NavigateTo(NavigateUrl()); } else { AddModuleMessage(Localizer["Message.SaveValidation"], MessageType.Warning); } } catch (Exception ex) { await logger.LogError(ex, "Error Saving EventRegistration {Error}", ex.Message); AddModuleMessage(Localizer["Message.SaveError"], MessageType.Error); } } }