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.
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,14 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
||||
{
|
||||
public class EventRegistrationManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
||||
{
|
||||
private readonly IEventRepository _EventRegistrationRepository;
|
||||
private readonly IEventRepository _EventRepository;
|
||||
private readonly IResponseRepository _ResponseRepository;
|
||||
private readonly IDBContextDependencies _DBContextDependencies;
|
||||
|
||||
public EventRegistrationManager(IEventRepository EventRegistrationRepository, IDBContextDependencies DBContextDependencies)
|
||||
public EventRegistrationManager(IEventRepository EventRegistrationRepository, IResponseRepository ResponseRepository, IDBContextDependencies DBContextDependencies)
|
||||
{
|
||||
_EventRegistrationRepository = EventRegistrationRepository;
|
||||
_EventRepository = EventRegistrationRepository;
|
||||
_ResponseRepository = ResponseRepository;
|
||||
_DBContextDependencies = DBContextDependencies;
|
||||
}
|
||||
|
||||
@ -36,8 +38,9 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
||||
|
||||
public string ExportModule(Oqtane.Models.Module module)
|
||||
{
|
||||
// TODO: Export event Responses as well.
|
||||
string content = "";
|
||||
List<Models.Event> EventRegistrations = _EventRegistrationRepository.GetEvents(module.ModuleId).ToList();
|
||||
List<Models.Event> EventRegistrations = _EventRepository.GetEvents(module.ModuleId).ToList();
|
||||
if (EventRegistrations != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize(EventRegistrations);
|
||||
@ -47,6 +50,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
||||
|
||||
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
||||
{
|
||||
// TODO: Import event Responses as well.
|
||||
List<Models.Event> EventRegistrations = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
@ -56,7 +60,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
||||
{
|
||||
foreach(var EventRegistration in EventRegistrations)
|
||||
{
|
||||
_EventRegistrationRepository.AddEvent(new Models.Event { ModuleId = module.ModuleId, Name = EventRegistration.Name });
|
||||
_EventRepository.AddEvent(new Models.Event { ModuleId = module.ModuleId, Name = EventRegistration.Name });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,14 +69,14 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
||||
{
|
||||
var searchContentList = new List<SearchContent>();
|
||||
|
||||
foreach (var EventRegistration in _EventRegistrationRepository.GetEvents(pageModule.ModuleId))
|
||||
foreach (var EventRegistration in _EventRepository.GetEvents(pageModule.ModuleId))
|
||||
{
|
||||
if (EventRegistration.ModifiedOn >= lastIndexedOn)
|
||||
{
|
||||
searchContentList.Add(new SearchContent
|
||||
{
|
||||
EntityName = "SZUAbsolventenvereinEventRegistration",
|
||||
EntityId = EventRegistration.EventRegistrationId.ToString(),
|
||||
EntityId = EventRegistration.EventId.ToString(),
|
||||
Title = EventRegistration.Name,
|
||||
Body = EventRegistration.Name,
|
||||
ContentModifiedBy = EventRegistration.ModifiedBy,
|
||||
|
@ -17,7 +17,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Migrations
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new EventRegistrationEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
var entityBuilder = new EventEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Create();
|
||||
|
||||
var entityBuilder2 = new EventResponseEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
@ -26,7 +26,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Migrations
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new EventRegistrationEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
var entityBuilder = new EventEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Drop();
|
||||
var entityBuilder2 = new EventResponseEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder2.Drop();
|
||||
|
@ -7,29 +7,29 @@ using Oqtane.Migrations.EntityBuilders;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Migrations.EntityBuilders
|
||||
{
|
||||
public class EventRegistrationEntityBuilder : AuditableBaseEntityBuilder<EventRegistrationEntityBuilder>
|
||||
public class EventEntityBuilder : AuditableBaseEntityBuilder<EventEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SZUAbsolventenvereinEvent";
|
||||
private readonly PrimaryKey<EventRegistrationEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinEvent", x => x.EventRegistrationId);
|
||||
private readonly ForeignKey<EventRegistrationEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinEvent_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||
private readonly PrimaryKey<EventEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinEvent", x => x.EventId);
|
||||
private readonly ForeignKey<EventEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinEvent_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||
|
||||
public EventRegistrationEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
public EventEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
ForeignKeys.Add(_moduleForeignKey);
|
||||
}
|
||||
|
||||
protected override EventRegistrationEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
protected override EventEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
EventRegistrationId = AddAutoIncrementColumn(table,"EventRegistrationId");
|
||||
EventId = AddAutoIncrementColumn(table,"EventId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
Name = AddMaxStringColumn(table,"Name");
|
||||
AddAuditableColumns(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> EventRegistrationId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> EventId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||
}
|
@ -13,7 +13,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Migrations.EntityBuilder
|
||||
private const string _entityTableName = "SZUAbsolventenvereinEventResponse";
|
||||
private readonly PrimaryKey<EventResponseEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinEventResponse", x => x.EventResponseId);
|
||||
private readonly ForeignKey<EventResponseEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinEventResponse_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||
private readonly ForeignKey<EventResponseEntityBuilder> _eventForeignKey = new("FK_SZUAbsolventenvereinEventResponse_Event", x => x.EventRegistrationId, "SZUAbsolventenvereinEvent", "EventRegistrationId", ReferentialAction.Cascade);
|
||||
private readonly ForeignKey<EventResponseEntityBuilder> _eventForeignKey = new("FK_SZUAbsolventenvereinEventResponse_Event", x => x.EventRegistrationId, "SZUAbsolventenvereinEvent", "EventId", ReferentialAction.Cascade);
|
||||
private readonly ForeignKey<EventResponseEntityBuilder> _ownerForeignKey = new("FK_SZUAbsolventenvereinEventResponse_User_Owner", x => x.OwnerId, "User", "UserId", ReferentialAction.Cascade);
|
||||
|
||||
public EventResponseEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
|
@ -34,7 +34,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Repository
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Event.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventRegistrationId);
|
||||
return db.Event.AsNoTracking().FirstOrDefault(item => item.EventId == EventRegistrationId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Models;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
|
||||
{
|
||||
public interface IResponseRepository
|
||||
{
|
||||
IEnumerable<Models.Response> GetResponses(int ModuleId);
|
||||
Models.Response GetResponse(int EventRegistrationId);
|
||||
Models.Response GetResponse(int EventRegistrationId, bool tracking);
|
||||
Models.Response AddResponse(Models.Event EventRegistration);
|
||||
Models.Response UpdateResponse(Models.Event EventRegistration);
|
||||
void DeleteResponse(int EventRegistrationId);
|
||||
IEnumerable<Response> GetResponses(int ModuleId);
|
||||
IEnumerable<Response> GetResponses(int EventId, int ModuleId);
|
||||
Response GetResponse(int EventRegistrationId);
|
||||
Response GetResponse(int EventRegistrationId, bool tracking);
|
||||
Response GetResponse(int EventId, int OwnerId);
|
||||
Response GetResponse(int EventId, int OwnerId, bool tracking);
|
||||
Response AddResponse(Response EventResponse);
|
||||
Response UpdateResponse(Response EventResponse);
|
||||
void DeleteResponse(int EventResponseId);
|
||||
}
|
||||
}
|
||||
|
89
Server/Repository/ResponseRepository.cs
Normal file
89
Server/Repository/ResponseRepository.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Models;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
|
||||
{
|
||||
public class ResponseRepository : IResponseRepository, ITransientService
|
||||
{
|
||||
private readonly IDbContextFactory<EventRegistrationContext> _factory;
|
||||
|
||||
public ResponseRepository(IDbContextFactory<EventRegistrationContext> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
public IEnumerable<Response> GetResponses(int ModuleId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
return db.Response.Where(item => item.ModuleId == ModuleId).ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Response> GetResponses(int EventId, int ModuleId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
return db.Response.Where(item => item.ModuleId == ModuleId && item.EventRegistrationId == EventId).ToList();
|
||||
}
|
||||
|
||||
public Response GetResponse(int EventRegistrationId)
|
||||
{
|
||||
return GetResponse(EventRegistrationId, true);
|
||||
}
|
||||
|
||||
public Response GetResponse(int EventRegistrationId, bool tracking)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
if (tracking)
|
||||
{
|
||||
return db.Response.Find(EventRegistrationId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Response.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventRegistrationId);
|
||||
}
|
||||
}
|
||||
|
||||
public Response GetResponse(int EventId, int OwnerId)
|
||||
{
|
||||
return GetResponse(EventId, OwnerId, true);
|
||||
}
|
||||
|
||||
public Response GetResponse(int EventId, int OwnerId, bool tracking)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
if (tracking)
|
||||
{
|
||||
return db.Response.FirstOrDefault(item => item.EventRegistrationId == EventId && item.OwnerId == OwnerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Response.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventId && item.OwnerId == OwnerId);
|
||||
}
|
||||
}
|
||||
|
||||
public Response AddResponse(Response EventResponse)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Response.Add(EventResponse);
|
||||
db.SaveChanges();
|
||||
return EventResponse;
|
||||
}
|
||||
|
||||
public Response UpdateResponse(Response EventResponse)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Entry(EventResponse).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return EventResponse;
|
||||
}
|
||||
|
||||
public void DeleteResponse(int EventRegistrationId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
Response EventResponse = db.Response.Find(EventRegistrationId);
|
||||
db.Response.Remove(EventResponse);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Extensions;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Security;
|
||||
@ -14,15 +15,17 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
{
|
||||
public class ServerEventRegistrationService : IEventRegistrationService
|
||||
{
|
||||
private readonly IEventRepository _EventRegistrationRepository;
|
||||
private readonly IEventRepository _EventRepository;
|
||||
private readonly IResponseRepository _ResponseRepository;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly Alias _alias;
|
||||
|
||||
public ServerEventRegistrationService(IEventRepository EventRegistrationRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
public ServerEventRegistrationService(IEventRepository EventRepository, IResponseRepository ResponseRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_EventRegistrationRepository = EventRegistrationRepository;
|
||||
_EventRepository = EventRepository;
|
||||
_ResponseRepository = ResponseRepository;
|
||||
_userPermissions = userPermissions;
|
||||
_logger = logger;
|
||||
_accessor = accessor;
|
||||
@ -33,7 +36,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, NewEvent.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
NewEvent = _EventRegistrationRepository.AddEvent(NewEvent);
|
||||
NewEvent = _EventRepository.AddEvent(NewEvent);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "EventRegistration Added {NewEvent}", NewEvent);
|
||||
}
|
||||
else
|
||||
@ -44,32 +47,90 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
return Task.FromResult(NewEvent);
|
||||
}
|
||||
|
||||
public Task<Response> AddOrUpdateResponseAsync(int EventId, int ModuleId, bool ResponseType)
|
||||
public Task<Response> AddResponseAsync(Response Response)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, Response.ModuleId, PermissionNames.View))
|
||||
{
|
||||
Response = _ResponseRepository.AddResponse(Response);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "EventRegistration Added {NewEvent}", Response);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Add Attempt {NewEvent}", Response);
|
||||
Response = null;
|
||||
}
|
||||
return Task.FromResult(Response);
|
||||
}
|
||||
|
||||
public Task<Response> UpdateResponseAsync(Response Response)
|
||||
{
|
||||
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, Response.ModuleId, PermissionNames.View))
|
||||
{
|
||||
Response = _ResponseRepository.UpdateResponse(Response);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "EventRegistration Added {NewEvent}", Response);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Add Attempt {NewEvent}", Response);
|
||||
Response = null;
|
||||
}
|
||||
return Task.FromResult(Response);
|
||||
}
|
||||
|
||||
public Task DeleteEventAsync(int EventId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
_EventRegistrationRepository.DeleteEvent(EventId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "EventRegistration Deleted {EventId}", EventId);
|
||||
_EventRepository.DeleteEvent(EventId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Event Deleted {EventId}", EventId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Delete Attempt {EventId} {ModuleId}", EventId, ModuleId);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Delete Attempt {EventId} {ModuleId}", EventId, ModuleId);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<Event> GetEventAsync(int EventId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_EventRepository.GetEvent(EventId, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<(Event, Response)> GetEventDetails(int EventId, int ModuleId)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
Event currentEvent = _EventRepository.GetEvent(EventId);
|
||||
Response rsvp = _ResponseRepository.GetResponse(EventId, _accessor.HttpContext.User.UserId());
|
||||
return Task.FromResult((currentEvent, rsvp));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<Response>> GetEventResponses(int EventId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
return Task.FromResult(_ResponseRepository.GetResponses(EventId, ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Response Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
@ -77,11 +138,11 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_EventRegistrationRepository.GetEvents(ModuleId).ToList());
|
||||
return Task.FromResult(_EventRepository.GetEvents(ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {ModuleId}", ModuleId);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Events Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -90,17 +151,19 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, NewEvent.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
NewEvent = _EventRegistrationRepository.UpdateEvent(NewEvent);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "EventRegistration Updated {NewEvent}", NewEvent);
|
||||
NewEvent = _EventRepository.UpdateEvent(NewEvent);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Event Updated {NewEvent}", NewEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Update Attempt {NewEvent}", NewEvent);
|
||||
_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)
|
||||
@ -147,5 +210,8 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user