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:
@ -30,7 +30,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
int ModuleId;
|
||||
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
||||
{
|
||||
return await _EventRegistrationService.GetEventRegistrationsAsync(ModuleId);
|
||||
return await _EventRegistrationService.GetEventsAsync(ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -45,7 +45,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<Models.Event> Get(int id, int moduleid)
|
||||
{
|
||||
Models.Event EventRegistration = await _EventRegistrationService.GetEventRegistrationAsync(id, moduleid);
|
||||
Models.Event EventRegistration = await _EventRegistrationService.GetEventAsync(id, moduleid);
|
||||
if (EventRegistration != null && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
return EventRegistration;
|
||||
@ -65,7 +65,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
{
|
||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
EventRegistration = await _EventRegistrationService.AddEventRegistrationAsync(EventRegistration);
|
||||
EventRegistration = await _EventRegistrationService.AddEventAsync(EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -81,9 +81,9 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task<Models.Event> Put(int id, [FromBody] Models.Event EventRegistration)
|
||||
{
|
||||
if (ModelState.IsValid && EventRegistration.EventRegistrationId == id && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
if (ModelState.IsValid && EventRegistration.EventId == id && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
EventRegistration = await _EventRegistrationService.UpdateEventRegistrationAsync(EventRegistration);
|
||||
EventRegistration = await _EventRegistrationService.UpdateEventAsync(EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -99,10 +99,10 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task Delete(int id, int moduleid)
|
||||
{
|
||||
Models.Event EventRegistration = await _EventRegistrationService.GetEventRegistrationAsync(id, moduleid);
|
||||
Models.Event EventRegistration = await _EventRegistrationService.GetEventAsync(id, moduleid);
|
||||
if (EventRegistration != null && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
await _EventRegistrationService.DeleteEventRegistrationAsync(id, EventRegistration.ModuleId);
|
||||
await _EventRegistrationService.DeleteEventAsync(id, EventRegistration.ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -110,5 +110,27 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("details/{id}/{moduleid}")]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<(Models.Event, Models.Response)> GetDetails(int id, int moduleid)
|
||||
{
|
||||
Models.Event EventRegistration;
|
||||
Models.Response EventResponse;
|
||||
(EventRegistration, EventResponse) = await _EventRegistrationService.GetEventDetails(id, moduleid);
|
||||
if (EventRegistration != null && EventResponse != null && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
return (EventRegistration, EventResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {EventRegistrationId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return (null, null);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add Event Response Endpoints.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user