Compare commits
15 Commits
fad59d9311
...
kh-charts-
| Author | SHA1 | Date | |
|---|---|---|---|
| 647c4f00d2 | |||
| a31292e476 | |||
| ab237de4c8 | |||
| 81ac7cf761 | |||
| 9b1ea5ada1 | |||
| 9eca4dd779 | |||
| ce68c5eb1d | |||
| 1359aee2b1 | |||
| 7929f0bed6 | |||
| f86287783c | |||
| 669cc79678 | |||
| 7694fc1e08 | |||
| 835795f526 | |||
| e12e4c5325 | |||
| 2ed210e20f |
@ -11,5 +11,20 @@ namespace SZUAbsolventenverein.Module.EventRegistration
|
||||
{
|
||||
_jsRuntime = jsRuntime;
|
||||
}
|
||||
|
||||
public async Task CreateChart(string divid, string type, string[] labels, object[] datasets, object options)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _jsRuntime.InvokeVoidAsync(
|
||||
"SZUAbsolventenverein.EventRegistration.createChart",
|
||||
divid, type, (object) labels, (object) datasets, options);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// handle exception
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
@using Oqtane.Modules.Controls
|
||||
@using Oqtane
|
||||
@using Oqtane.Modules.Controls
|
||||
@using Oqtane.Themes.Controls
|
||||
@using SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
@using SZUAbsolventenverein.Module.EventRegistration.Models
|
||||
@using System.Text.RegularExpressions
|
||||
|
||||
@namespace SZUAbsolventenverein.Module.EventRegistration
|
||||
@inherits ModuleBase
|
||||
@inject IEventRegistrationService EventRegistrationService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IStringLocalizer<Edit> Localizer
|
||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||
@inject IUserService UserService
|
||||
@inject IProfileService ProfileService
|
||||
@inject ISettingService SettingService
|
||||
|
||||
<h3>Anmeldung zum Event</h3>
|
||||
|
||||
@ -23,16 +30,12 @@
|
||||
<p class="mt-2"><strong>Status: </strong>
|
||||
@if (Status == true)
|
||||
{
|
||||
<span class ="fontsizeInf">@Localizer["Zugesagt"]</span>
|
||||
|
||||
<br />
|
||||
<button class="btn btn-danger" @onclick="Absage">@Localizer["Absagen"]</button>
|
||||
<span class ="fontsizeInf">@Localizer["Zugesagt"]</span><br />
|
||||
<p><button class="btn btn-danger" @onclick="Absage">@Localizer["Absagen"]</button></p>
|
||||
} else
|
||||
{
|
||||
<span class="fontsizeInf"> @Localizer["Abgesagt"]</span>
|
||||
|
||||
<br class="mt-2" />
|
||||
<button class="btn btn-success" @onclick="Zusage">@Localizer["Zusagen"]</button>
|
||||
<span class="fontsizeInf"> @Localizer["Abgesagt"]</span><br />
|
||||
<p><button class="btn btn-success" @onclick="Zusage">@Localizer["Zusagen"]</button></p>
|
||||
}
|
||||
</p>
|
||||
} else {
|
||||
@ -44,11 +47,10 @@
|
||||
} else
|
||||
{
|
||||
<p class="mt-3">Um dich für dieses Event zu registrieren, muss man sich zuerst anmelden.</p>
|
||||
<div class="gap-2">
|
||||
<Login />
|
||||
@* @if(PageState.Site.AllowRegistration)
|
||||
{
|
||||
<Register />
|
||||
} *@
|
||||
<UserProfile ShowRegister="true" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
@ -75,8 +77,12 @@
|
||||
private Response _response;
|
||||
private bool? Status;
|
||||
|
||||
private List<Profile> _profiles = new List<Profile>();
|
||||
private Dictionary<string, string> _settings;
|
||||
|
||||
private async Task SendResponse(bool response)
|
||||
{
|
||||
if(ValidateProfiles()) {
|
||||
if(_response == null)
|
||||
{
|
||||
_response = new Response();
|
||||
@ -91,6 +97,14 @@
|
||||
_response = await EventRegistrationService.UpdateResponseAsync(_response);
|
||||
}
|
||||
if(_response != null) Status = _response.ResponseType;
|
||||
} else
|
||||
{
|
||||
var currentPathAndQuery = new Uri(NavigationManager.Uri).PathAndQuery;
|
||||
var encodedReturnUrl = Uri.EscapeDataString(currentPathAndQuery);
|
||||
var link = $"/profile?tab=Profile&returnurl={encodedReturnUrl}";
|
||||
|
||||
AddModuleMessage(string.Format(SharedLocalizer["ProfileRequired"], $"Vervollständige hier dein Profil mit deinem Jahrgang und deiner Fachrichtung: <a href=\"{link}\">Link zum Profil</a>"), MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private async void Zusage()
|
||||
@ -107,6 +121,15 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
if(PageState.User != null) {
|
||||
_profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||
var user = await UserService.GetUserAsync(PageState.User.UserId, PageState.Site.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
_settings = user.Settings;
|
||||
}
|
||||
}
|
||||
|
||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||
|
||||
Event currentEvent;
|
||||
@ -132,4 +155,46 @@
|
||||
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool ValidateProfiles()
|
||||
{
|
||||
foreach (Profile profile in _profiles)
|
||||
{
|
||||
var value = GetProfileValue(profile.Name, string.Empty);
|
||||
if (string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(profile.DefaultValue))
|
||||
{
|
||||
_settings = SettingService.SetSetting(_settings, profile.Name, profile.DefaultValue);
|
||||
}
|
||||
if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||
{
|
||||
if (profile.IsRequired && string.IsNullOrEmpty(value))
|
||||
{
|
||||
AddModuleMessage(string.Format(SharedLocalizer["ProfileRequired"], profile.Title), MessageType.Warning);
|
||||
return false;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(profile.Validation))
|
||||
{
|
||||
Regex regex = new Regex(profile.Validation);
|
||||
bool valid = regex.Match(value).Success;
|
||||
if (!valid)
|
||||
{
|
||||
AddModuleMessage(string.Format(SharedLocalizer["ProfileInvalid"], profile.Title), MessageType.Warning);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||
{
|
||||
string value = SettingService.GetSetting(_settings, SettingName, DefaultValue);
|
||||
if (value.Contains("]"))
|
||||
{
|
||||
value = value.Substring(value.IndexOf("]") + 1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
{
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
||||
}
|
||||
<div id="chart"></div>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
@ -53,7 +54,9 @@
|
||||
|
||||
public override List<Resource> Resources => new List<Resource>()
|
||||
{
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" },
|
||||
new Resource { ResourceType = ResourceType.Script, Bundle = "ChartJS", Url = "https://cdn.jsdelivr.net/npm/chart.js" },
|
||||
new Resource { ResourceType = ResourceType.Script, Bundle = "ChartJS", Url = ModulePath() + "Module.js"}
|
||||
};
|
||||
|
||||
|
||||
@ -72,6 +75,9 @@
|
||||
private string _modifiedby;
|
||||
private DateTime _modifiedon;
|
||||
|
||||
bool _refresh = false;
|
||||
private List<Response> _responses;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
@ -92,6 +98,10 @@
|
||||
_modifiedby = EventRegistration.ModifiedBy;
|
||||
_modifiedon = EventRegistration.ModifiedOn;
|
||||
}
|
||||
|
||||
_responses = await EventRegistrationService.GetEventResponses(_id, ModuleState.ModuleId);
|
||||
Console.WriteLine("Responses count: " + (_responses != null ? _responses.Count.ToString() : "null"));
|
||||
_refresh = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -101,6 +111,38 @@
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
try
|
||||
{
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
|
||||
Console.WriteLine("Responses count: " + (_responses != null ? _responses.Count.ToString() : "null"));
|
||||
|
||||
if (_refresh && _responses != null)
|
||||
{
|
||||
List<string> labels = new List<string>();
|
||||
List<object> datasets = new List<object>();
|
||||
string[] colors = new string[] { "#FF0000", "#FF8000", "#FFFF00", "#00FF00", "#00FFFF", "#0080FF", "#0000FF", "#8000FF", "#FF00FF", "#CCCCCC" };
|
||||
|
||||
labels.AddRange("Zusage", "Absage");
|
||||
datasets.Add(new { label = "ALL", data = new int[] { _responses.Count(r => r.ResponseType == true), _responses.Count(r => r.ResponseType == false) }, fill = false, backgroundColor = colors });
|
||||
// datasets.Add(new { label = "2024", data = new int[] { 1, 1 }, fill = false, backgroundColor = colors });
|
||||
object options = new { maintainAspectRatio = false, legend = new { display = true, position = "bottom", labels = new { fontColor = "white", fontSize = 16 } } };
|
||||
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.CreateChart("chart", "pie", labels.ToArray(), datasets.ToArray(), options);
|
||||
|
||||
_refresh = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Rendering Chart {Error}", ex.Message);
|
||||
AddModuleMessage("Error Rendering Chart", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
try
|
||||
|
||||
@ -9,9 +9,9 @@ namespace SZUAbsolventenverein.Module.EventRegistration
|
||||
{
|
||||
Name = "EventRegistration",
|
||||
Description = "A module to manage registration for events",
|
||||
Version = "1.0.14",
|
||||
Version = "1.0.17",
|
||||
ServerManagerType = "SZUAbsolventenverein.Module.EventRegistration.Manager.EventRegistrationManager, SZUAbsolventenverein.Module.EventRegistration.Server.Oqtane",
|
||||
ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7,1.0.8,1.0.9,1.0.10,1.0.11,1.0.12,1.0.13,1.0.14",
|
||||
ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7,1.0.8,1.0.9,1.0.10,1.0.11,1.0.12,1.0.13,1.0.14,1.0.15,1.0.16,1.0.17",
|
||||
Dependencies = "SZUAbsolventenverein.Module.EventRegistration.Shared.Oqtane",
|
||||
PackageName = "SZUAbsolventenverein.Module.EventRegistration"
|
||||
};
|
||||
|
||||
@ -13,11 +13,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.8" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.9" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="9.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -15,27 +15,6 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
|
||||
private string Apiurl => CreateApiUrl("EventRegistration");
|
||||
|
||||
/*public async Task<List<Models.Event>> GetEventRegistrationsAsync(int ModuleId)
|
||||
{
|
||||
List<Models.Event> EventRegistrations = await GetJsonAsync<List<Models.Event>>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Models.Event>().ToList());
|
||||
return EventRegistrations.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Models.Event> GetEventRegistrationAsync(int EventRegistrationId, int ModuleId)
|
||||
{
|
||||
return await GetJsonAsync<Models.Event>(CreateAuthorizationPolicyUrl($"{Apiurl}/{EventRegistrationId}/{ModuleId}", EntityNames.Module, ModuleId));
|
||||
}
|
||||
|
||||
public async Task<Models.Event> AddEventRegistrationAsync(Models.Event EventRegistration)
|
||||
{
|
||||
return await PostJsonAsync<Models.Event>(CreateAuthorizationPolicyUrl($"{Apiurl}", EntityNames.Module, EventRegistration.ModuleId), EventRegistration);
|
||||
}
|
||||
|
||||
public async Task<Models.Event> UpdateEventRegistrationAsync(Models.Event EventRegistration)
|
||||
{
|
||||
return await PutJsonAsync<Models.Event>(CreateAuthorizationPolicyUrl($"{Apiurl}/{EventRegistration.EventRegistrationId}", EntityNames.Module, EventRegistration.ModuleId), EventRegistration);
|
||||
}*/
|
||||
|
||||
public async Task<List<Event>> GetEventsAsync(int ModuleId)
|
||||
{
|
||||
List<Event> EventRegistrations = await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Event>().ToList());
|
||||
@ -51,9 +30,9 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
return await PostJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}", EntityNames.Module, NewEvent.ModuleId), NewEvent);
|
||||
}
|
||||
|
||||
public async Task<Event> UpdateEventAsync(Event NewEvent)
|
||||
public async Task<Event> UpdateEventAsync(Event UpdatedEvent)
|
||||
{
|
||||
return await PutJsonAsync<Event>(CreateAuthorizationPolicyUrl($"{Apiurl}/{NewEvent.EventId}", EntityNames.Module, NewEvent.ModuleId), NewEvent);
|
||||
return await PutJsonAsync<Event>(CreateAuthorizationPolicyUrl($"{Apiurl}/{UpdatedEvent.EventId}", EntityNames.Module, UpdatedEvent.ModuleId), UpdatedEvent);
|
||||
}
|
||||
|
||||
public async Task DeleteEventAsync(int EventId, int ModuleId)
|
||||
@ -76,7 +55,12 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
return await GetJsonAsync<(Event, Response)>(CreateAuthorizationPolicyUrl($"{Apiurl}/details/{EventId}/{ModuleId}", EntityNames.Module, ModuleId));
|
||||
}
|
||||
|
||||
public Task<List<Response>> GetEventResponses(int EventId, int ModuleId)
|
||||
public async Task<List<Response>> GetEventResponses(int EventId, int ModuleId)
|
||||
{
|
||||
return await GetJsonAsync<List<Response>>(CreateAuthorizationPolicyUrl($"{Apiurl}/all-responses/{EventId}/{ModuleId}", EntityNames.Module, ModuleId));
|
||||
}
|
||||
|
||||
public Task<List<Response>> GetRecommendedEventResponses(int EventId, int MouleId)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>$projectname$</id>
|
||||
<version>1.0.14</version>
|
||||
<version>1.0.17</version>
|
||||
<authors>SZUAbsolventenverein</authors>
|
||||
<owners>SZUAbsolventenverein</owners>
|
||||
<title>EventRegistration</title>
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
TargetFramework=$1
|
||||
ProjectName=$2
|
||||
|
||||
cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName$.Client.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName$.Client.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName$.Server.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName$.Server.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName$.Shared.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName$.Shared.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName.Client.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName.Client.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName.Server.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName.Server.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName.Shared.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName.Shared.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
|
||||
cp -rf "../Server/wwwroot/"* "../../oqtane.framework/Oqtane.Server/wwwroot/"
|
||||
@ -131,6 +131,24 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("all-respones/{id}/{moduleid}")]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<List<Models.Response>> GetResponses(int id, int moduleid)
|
||||
{
|
||||
List<Models.Response> eventResponses = await _EventRegistrationService.GetEventResponses(id, moduleid);
|
||||
if (eventResponses != null && IsAuthorizedEntityId(EntityNames.Module, moduleid))
|
||||
{
|
||||
return eventResponses;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {EventRegistrationId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add Event Response Endpoints.
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,10 +19,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -122,6 +122,34 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<Event>> GetEventsAsync(int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_EventRepository.GetEvents(ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Events Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Event> UpdateEventAsync(Event UpdatedEvent)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, UpdatedEvent.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
UpdatedEvent = _EventRepository.UpdateEvent(UpdatedEvent);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Event Updated {NewEvent}", UpdatedEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Update Attempt {NewEvent}", UpdatedEvent);
|
||||
UpdatedEvent = null;
|
||||
}
|
||||
return Task.FromResult(UpdatedEvent);
|
||||
}
|
||||
|
||||
public Task<(Event, Response)> GetEventDetails(int EventId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
@ -148,85 +176,13 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Response Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<Response>> GetRecommendedEventResponses(int EventId, int MouleId)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<List<Event>> GetEventsAsync(int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_EventRepository.GetEvents(ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Events Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Event> UpdateEventAsync(Event NewEvent)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, NewEvent.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
NewEvent = _EventRepository.UpdateEvent(NewEvent);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Event Updated {NewEvent}", NewEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Update Attempt {NewEvent}", NewEvent);
|
||||
NewEvent = null;
|
||||
}
|
||||
return Task.FromResult(NewEvent);
|
||||
}
|
||||
|
||||
// TODO: Implement the methods for EventResponses
|
||||
|
||||
/*
|
||||
|
||||
public Task<Models.Event> GetEventRegistrationAsync(int EventRegistrationId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_EventRegistrationRepository.GetEventRegistration(EventRegistrationId));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {EventRegistrationId} {ModuleId}", EventRegistrationId, ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Models.Event> AddEventRegistrationAsync(Models.Event EventRegistration)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, EventRegistration.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
EventRegistration = _EventRegistrationRepository.AddEventRegistration(EventRegistration);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "EventRegistration Added {EventRegistration}", EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Add Attempt {EventRegistration}", EventRegistration);
|
||||
EventRegistration = null;
|
||||
}
|
||||
return Task.FromResult(EventRegistration);
|
||||
}
|
||||
|
||||
public Task<Models.Event> UpdateEventRegistrationAsync(Models.Event EventRegistration)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, EventRegistration.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
EventRegistration = _EventRegistrationRepository.UpdateEventRegistration(EventRegistration);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "EventRegistration Updated {EventRegistration}", EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Update Attempt {EventRegistration}", EventRegistration);
|
||||
EventRegistration = null;
|
||||
}
|
||||
return Task.FromResult(EventRegistration);
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
private void SendEventResponseNotification(string subject, string body)
|
||||
{
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.event-card:hover {
|
||||
border-color: #66ccff;
|
||||
transform: translateY(-4px);
|
||||
|
||||
box-shadow: 0 6px 14px rgba(0,0,0,.5);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,4 +2,25 @@
|
||||
var SZUAbsolventenverein = SZUAbsolventenverein || {};
|
||||
|
||||
SZUAbsolventenverein.EventRegistration = {
|
||||
createChart: async function (divid, type, labels, datasets, options) {
|
||||
var container = document.getElementById(divid);
|
||||
if (container.hasChildNodes()) {
|
||||
while (container.firstChild) {
|
||||
container.removeChild(container.firstChild);
|
||||
}
|
||||
}
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.id = divid + '-canvas';
|
||||
container.appendChild(canvas);
|
||||
var ctx = canvas.getContext('2d');
|
||||
var chart = new Chart(ctx, {
|
||||
type: type,
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: datasets
|
||||
},
|
||||
options: options
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
@ -5,26 +5,84 @@ using SZUAbsolventenverein.Module.EventRegistration.Models;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Methods for managing events and their responses
|
||||
/// </summary>
|
||||
public interface IEventRegistrationService
|
||||
{
|
||||
/* Reine Events */
|
||||
/// <summary>
|
||||
/// Alle Events eines Moduls abrufen
|
||||
/// </summary>
|
||||
/// <param name="ModuleId">das aufrufende Modul</param>
|
||||
/// <returns>Liste aller Veranstaltungen</returns>
|
||||
Task<List<Event>> GetEventsAsync(int ModuleId);
|
||||
/// <summary>
|
||||
/// Ein bestimmtes Event abrufen
|
||||
/// </summary>
|
||||
/// <param name="EventId">das aufzurufende Event</param>
|
||||
/// <param name="ModuleId">das aufrufende Modul</param>
|
||||
/// <returns>Das Event selbst</returns>
|
||||
Task<Event> GetEventAsync(int EventId, int ModuleId);
|
||||
|
||||
/// <summary>
|
||||
/// Ein neues Event anlegen
|
||||
/// </summary>
|
||||
/// <param name="NewEvent">das anzulegende Event</param>
|
||||
/// <returns>das angelegte Event</returns>
|
||||
Task<Event> AddEventAsync(Event NewEvent);
|
||||
|
||||
Task<Event> UpdateEventAsync(Event NewEvent);
|
||||
/// <summary>
|
||||
/// Ändern eines bestehenden Events
|
||||
/// </summary>
|
||||
/// <param name="UpdatedEvent">Das Eventobjekt mit aktualisierte Event</param>
|
||||
/// <returns>das gespeicherte Event</returns>
|
||||
Task<Event> UpdateEventAsync(Event UpdatedEvent);
|
||||
|
||||
/// <summary>
|
||||
/// Löschen eines Events
|
||||
/// </summary>
|
||||
/// <param name="EventId">das zu löschende Event</param>
|
||||
/// <param name="ModuleId">das aufrufende Modul</param>
|
||||
/// <returns></returns>
|
||||
Task DeleteEventAsync(int EventId, int ModuleId);
|
||||
|
||||
|
||||
/* Events & Responses */
|
||||
/// <summary>
|
||||
/// Eine neue Antwort zu einem Event hinzufügen
|
||||
/// </summary>
|
||||
/// <param name="Response">die Antwort</param>
|
||||
/// <returns>die gespeicherte Antwort</returns>
|
||||
Task<Response> AddResponseAsync(Response Response);
|
||||
|
||||
/// <summary>
|
||||
/// Eine bestehende Antwort zu einem Event aktualisieren
|
||||
/// </summary>
|
||||
/// <param name="Response">die neue Antwort</param>
|
||||
/// <returns>die gespeicherte neue Antwort</returns>
|
||||
Task<Response> UpdateResponseAsync(Response Response);
|
||||
|
||||
/// <summary>
|
||||
/// Details zu einem Event abrufen (Event + Antwort vom auktuellen Benutzer)
|
||||
/// </summary>
|
||||
/// <param name="EventId">das aufzurufende Event</param>
|
||||
/// <param name="ModuleId">das aufrufende Modul</param>
|
||||
/// <returns>Tuple aus Event und Antwort</returns>
|
||||
Task<(Event, Response)> GetEventDetails(int EventId, int ModuleId);
|
||||
|
||||
/// <summary>
|
||||
/// Alle Antworten zu einem Event abrufen
|
||||
/// </summary>
|
||||
/// <param name="EventId">das Event, dessen Antworten geladen werden sollen</param>
|
||||
/// <param name="ModuleId">das aufrufende Modul</param>
|
||||
/// <returns>Liste aller Antworten auf das Event</returns>
|
||||
Task<List<Response>> GetEventResponses(int EventId, int ModuleId);
|
||||
|
||||
/// <summary>
|
||||
/// 10 Antworten eines Events abrufen, welche gewichtet zurückgeliefert werden
|
||||
/// </summary>
|
||||
/// <param name="EventId">das aufzurufende Event</param>
|
||||
/// <param name="MouleId">das aufrufende Modul</param>
|
||||
/// <returns>Liste mit 10 </returns>
|
||||
Task<List<Response>> GetRecommendedEventResponses(int EventId, int MouleId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user