diff --git a/Server/Services/EventRegistrationService.cs b/Server/Services/EventRegistrationService.cs index a7a964f..79a4e8f 100644 --- a/Server/Services/EventRegistrationService.cs +++ b/Server/Services/EventRegistrationService.cs @@ -31,7 +31,17 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services public Task AddEventAsync(Event NewEvent) { - throw new System.NotImplementedException(); + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, NewEvent.ModuleId, PermissionNames.Edit)) + { + NewEvent = _EventRegistrationRepository.AddEventRegistration(NewEvent); + _logger.Log(LogLevel.Information, this, LogFunction.Create, "EventRegistration Added {NewEvent}", NewEvent); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Add Attempt {NewEvent}", NewEvent); + NewEvent = null; + } + return Task.FromResult(NewEvent); } public Task AddOrUpdateResponseAsync(int EventId, int ModuleId, bool ResponseType) @@ -41,7 +51,16 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services public Task DeleteEventAsync(int EventId, int ModuleId) { - throw new System.NotImplementedException(); + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit)) + { + _EventRegistrationRepository.DeleteEventRegistration(EventId); + _logger.Log(LogLevel.Information, this, LogFunction.Delete, "EventRegistration Deleted {EventId}", EventId); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Delete Attempt {EventId} {ModuleId}", EventId, ModuleId); + } + return Task.CompletedTask; } public Task<(Event, Response)> GetEventDetails(int EventId, int ModuleId) @@ -55,16 +74,6 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services } public Task> GetEventsAsync(int ModuleId) - { - throw new System.NotImplementedException(); - } - - public Task UpdateEventAsync(Event NewEvent) - { - throw new System.NotImplementedException(); - } - - /*public Task> GetEventRegistrationsAsync(int ModuleId) { if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) { @@ -77,6 +86,23 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services } } + public Task UpdateEventAsync(Event NewEvent) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, NewEvent.ModuleId, PermissionNames.Edit)) + { + NewEvent = _EventRegistrationRepository.UpdateEventRegistration(NewEvent); + _logger.Log(LogLevel.Information, this, LogFunction.Update, "EventRegistration Updated {NewEvent}", NewEvent); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Update Attempt {NewEvent}", NewEvent); + NewEvent = null; + } + return Task.FromResult(NewEvent); + } + + /* + public Task GetEventRegistrationAsync(int EventRegistrationId, int ModuleId) { if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) @@ -120,18 +146,6 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services return Task.FromResult(EventRegistration); } - public Task DeleteEventRegistrationAsync(int EventRegistrationId, int ModuleId) - { - if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit)) - { - _EventRegistrationRepository.DeleteEventRegistration(EventRegistrationId); - _logger.Log(LogLevel.Information, this, LogFunction.Delete, "EventRegistration Deleted {EventRegistrationId}", EventRegistrationId); - } - else - { - _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Delete Attempt {EventRegistrationId} {ModuleId}", EventRegistrationId, ModuleId); - } - return Task.CompletedTask; }*/ } }