138 lines
4.3 KiB
Plaintext
138 lines
4.3 KiB
Plaintext
@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<Edit> Localizer
|
|
|
|
<h3>Anmeldung zum Event</h3>
|
|
|
|
<p>Willst du am Event (@_name) teilnehmen?</p>
|
|
<span>@_eventDate - @_location</span>
|
|
<div>
|
|
<p>@_description</p>
|
|
<p><strong>Erstellt von:</strong> @_createdby am @_createdon</p>
|
|
<p><strong>Zuletzt aktualisiert von:</strong> @_modifiedby am @_modifiedon</p>
|
|
</div>
|
|
|
|
@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>
|
|
}
|
|
} else
|
|
{
|
|
<p class="mt-3">Um dich für dieses Event zu registrieren, muss man sich zuerst anmelden.</p> <Login /><Register />
|
|
}
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
|
|
|
public override string Actions => "Details";
|
|
|
|
public override string Title => "Event Details";
|
|
|
|
public override List<Resource> Resources => new List<Resource>()
|
|
{
|
|
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
|
|
};
|
|
|
|
private ElementReference form;
|
|
private bool validated = false;
|
|
|
|
private int _id;
|
|
private string _name;
|
|
private string _description;
|
|
private DateTime _eventDate;
|
|
private string _location;
|
|
|
|
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;
|
|
_description = currentEvent.Description;
|
|
_eventDate = currentEvent.EventDate.ToLocalTime();
|
|
_location = currentEvent.Location;
|
|
_createdby = currentEvent.CreatedBy;
|
|
_createdon = currentEvent.CreatedOn.ToLocalTime();
|
|
_modifiedby = currentEvent.ModifiedBy;
|
|
_modifiedon = currentEvent.ModifiedOn.ToLocalTime();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|