Add project files.
This commit is contained in:
114
Server/Controllers/EventRegistrationController.cs
Normal file
114
Server/Controllers/EventRegistrationController.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Services;
|
||||
using Oqtane.Controllers;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Controllers
|
||||
{
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class EventRegistrationController : ModuleControllerBase
|
||||
{
|
||||
private readonly IEventRegistrationService _EventRegistrationService;
|
||||
|
||||
public EventRegistrationController(IEventRegistrationService EventRegistrationService, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor)
|
||||
{
|
||||
_EventRegistrationService = EventRegistrationService;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?moduleid=x
|
||||
[HttpGet]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<IEnumerable<Models.Event>> Get(string moduleid)
|
||||
{
|
||||
int ModuleId;
|
||||
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
||||
{
|
||||
return await _EventRegistrationService.GetEventRegistrationsAsync(ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {ModuleId}", moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}/{moduleid}")]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<Models.Event> Get(int id, int moduleid)
|
||||
{
|
||||
Models.Event EventRegistration = await _EventRegistrationService.GetEventRegistrationAsync(id, moduleid);
|
||||
if (EventRegistration != null && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
return EventRegistration;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {EventRegistrationId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task<Models.Event> Post([FromBody] Models.Event EventRegistration)
|
||||
{
|
||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
EventRegistration = await _EventRegistrationService.AddEventRegistrationAsync(EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Post Attempt {EventRegistration}", EventRegistration);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
EventRegistration = null;
|
||||
}
|
||||
return EventRegistration;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[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))
|
||||
{
|
||||
EventRegistration = await _EventRegistrationService.UpdateEventRegistrationAsync(EventRegistration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Put Attempt {EventRegistration}", EventRegistration);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
EventRegistration = null;
|
||||
}
|
||||
return EventRegistration;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}/{moduleid}")]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task Delete(int id, int moduleid)
|
||||
{
|
||||
Models.Event EventRegistration = await _EventRegistrationService.GetEventRegistrationAsync(id, moduleid);
|
||||
if (EventRegistration != null && IsAuthorizedEntityId(EntityNames.Module, EventRegistration.ModuleId))
|
||||
{
|
||||
await _EventRegistrationService.DeleteEventRegistrationAsync(id, EventRegistration.ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Delete Attempt {EventRegistrationId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
87
Server/Manager/EventRegistrationManager.cs
Normal file
87
Server/Manager/EventRegistrationManager.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Repository;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Repository;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
||||
{
|
||||
public class EventRegistrationManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
||||
{
|
||||
private readonly IEventRegistrationRepository _EventRegistrationRepository;
|
||||
private readonly IDBContextDependencies _DBContextDependencies;
|
||||
|
||||
public EventRegistrationManager(IEventRegistrationRepository EventRegistrationRepository, IDBContextDependencies DBContextDependencies)
|
||||
{
|
||||
_EventRegistrationRepository = EventRegistrationRepository;
|
||||
_DBContextDependencies = DBContextDependencies;
|
||||
}
|
||||
|
||||
public bool Install(Tenant tenant, string version)
|
||||
{
|
||||
return Migrate(new EventRegistrationContext(_DBContextDependencies), tenant, MigrationType.Up);
|
||||
}
|
||||
|
||||
public bool Uninstall(Tenant tenant)
|
||||
{
|
||||
return Migrate(new EventRegistrationContext(_DBContextDependencies), tenant, MigrationType.Down);
|
||||
}
|
||||
|
||||
public string ExportModule(Oqtane.Models.Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<Models.Event> EventRegistrations = _EventRegistrationRepository.GetEventRegistrations(module.ModuleId).ToList();
|
||||
if (EventRegistrations != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize(EventRegistrations);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
||||
{
|
||||
List<Models.Event> EventRegistrations = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
EventRegistrations = JsonSerializer.Deserialize<List<Models.Event>>(content);
|
||||
}
|
||||
if (EventRegistrations != null)
|
||||
{
|
||||
foreach(var EventRegistration in EventRegistrations)
|
||||
{
|
||||
_EventRegistrationRepository.AddEventRegistration(new Models.Event { ModuleId = module.ModuleId, Name = EventRegistration.Name });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<SearchContent>> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn)
|
||||
{
|
||||
var searchContentList = new List<SearchContent>();
|
||||
|
||||
foreach (var EventRegistration in _EventRegistrationRepository.GetEventRegistrations(pageModule.ModuleId))
|
||||
{
|
||||
if (EventRegistration.ModifiedOn >= lastIndexedOn)
|
||||
{
|
||||
searchContentList.Add(new SearchContent
|
||||
{
|
||||
EntityName = "SZUAbsolventenvereinEventRegistration",
|
||||
EntityId = EventRegistration.EventRegistrationId.ToString(),
|
||||
Title = EventRegistration.Name,
|
||||
Body = EventRegistration.Name,
|
||||
ContentModifiedBy = EventRegistration.ModifiedBy,
|
||||
ContentModifiedOn = EventRegistration.ModifiedOn
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(searchContentList);
|
||||
}
|
||||
}
|
||||
}
|
35
Server/Migrations/01000000_InitializeModule.cs
Normal file
35
Server/Migrations/01000000_InitializeModule.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Migrations.EntityBuilders;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Migrations
|
||||
{
|
||||
[DbContext(typeof(EventRegistrationContext))]
|
||||
[Migration("SZUAbsolventenverein.Module.EventRegistration.01.00.00.00")]
|
||||
public class InitializeModule : MultiDatabaseMigration
|
||||
{
|
||||
public InitializeModule(IDatabase database) : base(database)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new EventRegistrationEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Create();
|
||||
|
||||
var entityBuilder2 = new EventResponseEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder2.Create();
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new EventRegistrationEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Drop();
|
||||
var entityBuilder2 = new EventResponseEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder2.Drop();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Migrations.EntityBuilders
|
||||
{
|
||||
public class EventRegistrationEntityBuilder : AuditableBaseEntityBuilder<EventRegistrationEntityBuilder>
|
||||
{
|
||||
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);
|
||||
|
||||
public EventRegistrationEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
ForeignKeys.Add(_moduleForeignKey);
|
||||
}
|
||||
|
||||
protected override EventRegistrationEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
EventRegistrationId = AddAutoIncrementColumn(table,"EventRegistrationId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
Name = AddMaxStringColumn(table,"Name");
|
||||
AddAuditableColumns(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> EventRegistrationId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Migrations.EntityBuilders
|
||||
{
|
||||
public class EventResponseEntityBuilder : AuditableBaseEntityBuilder<EventResponseEntityBuilder>
|
||||
{
|
||||
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> _ownerForeignKey = new("FK_SZUAbsolventenvereinEventResponse_User_Owner", x => x.OwnerId, "User", "UserId", ReferentialAction.Cascade);
|
||||
|
||||
public EventResponseEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
ForeignKeys.Add(_moduleForeignKey);
|
||||
ForeignKeys.Add(_eventForeignKey);
|
||||
ForeignKeys.Add(_ownerForeignKey);
|
||||
}
|
||||
|
||||
protected override EventResponseEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
EventResponseId = AddAutoIncrementColumn(table, "EventResponseId");
|
||||
ResponseType = AddBooleanColumn(table, "ResponseType");
|
||||
OwnerId = AddIntegerColumn(table, "OwnerId");
|
||||
EventRegistrationId = AddIntegerColumn(table,"EventRegistrationId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
AddAuditableColumns(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> EventResponseId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> ResponseType { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> OwnerId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> EventRegistrationId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||
}
|
||||
}
|
28
Server/Repository/EventRegistrationContext.cs
Normal file
28
Server/Repository/EventRegistrationContext.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository.Databases.Interfaces;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
|
||||
{
|
||||
public class EventRegistrationContext : DBContextBase, ITransientService, IMultiDatabase
|
||||
{
|
||||
public virtual DbSet<Models.Event> Event { get; set; }
|
||||
public virtual DbSet<Models.Response> Response { get; set; }
|
||||
|
||||
public EventRegistrationContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<Models.Event>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinEvent"));
|
||||
builder.Entity<Models.Response>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinEventResponse"));
|
||||
}
|
||||
}
|
||||
}
|
65
Server/Repository/EventRegistrationRepository.cs
Normal file
65
Server/Repository/EventRegistrationRepository.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
|
||||
{
|
||||
public class EventRegistrationRepository : IEventRegistrationRepository, ITransientService
|
||||
{
|
||||
private readonly IDbContextFactory<EventRegistrationContext> _factory;
|
||||
|
||||
public EventRegistrationRepository(IDbContextFactory<EventRegistrationContext> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
public IEnumerable<Models.Event> GetEventRegistrations(int ModuleId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
return db.Event.Where(item => item.ModuleId == ModuleId).ToList();
|
||||
}
|
||||
|
||||
public Models.Event GetEventRegistration(int EventRegistrationId)
|
||||
{
|
||||
return GetEventRegistration(EventRegistrationId, true);
|
||||
}
|
||||
|
||||
public Models.Event GetEventRegistration(int EventRegistrationId, bool tracking)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
if (tracking)
|
||||
{
|
||||
return db.Event.Find(EventRegistrationId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Event.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventRegistrationId);
|
||||
}
|
||||
}
|
||||
|
||||
public Models.Event AddEventRegistration(Models.Event EventRegistration)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Event.Add(EventRegistration);
|
||||
db.SaveChanges();
|
||||
return EventRegistration;
|
||||
}
|
||||
|
||||
public Models.Event UpdateEventRegistration(Models.Event EventRegistration)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Entry(EventRegistration).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return EventRegistration;
|
||||
}
|
||||
|
||||
public void DeleteEventRegistration(int EventRegistrationId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
Models.Event EventRegistration = db.Event.Find(EventRegistrationId);
|
||||
db.Event.Remove(EventRegistration);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
15
Server/Repository/IEventRegistrationRepository.cs
Normal file
15
Server/Repository/IEventRegistrationRepository.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
|
||||
{
|
||||
public interface IEventRegistrationRepository
|
||||
{
|
||||
IEnumerable<Models.Event> GetEventRegistrations(int ModuleId);
|
||||
Models.Event GetEventRegistration(int EventRegistrationId);
|
||||
Models.Event GetEventRegistration(int EventRegistrationId, bool tracking);
|
||||
Models.Event AddEventRegistration(Models.Event EventRegistration);
|
||||
Models.Event UpdateEventRegistration(Models.Event EventRegistration);
|
||||
void DeleteEventRegistration(int EventRegistrationId);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
||||
<Version>1.0.0</Version>
|
||||
<Product>SZUAbsolventenverein.Module.EventRegistration</Product>
|
||||
<Authors>SZUAbsolventenverein</Authors>
|
||||
<Company>SZUAbsolventenverein</Company>
|
||||
<Description>A module to manage registration for events</Description>
|
||||
<Copyright>SZUAbsolventenverein</Copyright>
|
||||
<AssemblyName>SZUAbsolventenverein.Module.EventRegistration.Server.Oqtane</AssemblyName>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="wwwroot\_content\**\*.*" />
|
||||
<None Include="wwwroot\_content\**\*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\SZUAbsolventenverein.Module.EventRegistration.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Oqtane.Server"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Server.dll</HintPath></Reference>
|
||||
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll</HintPath></Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
101
Server/Services/EventRegistrationService.cs
Normal file
101
Server/Services/EventRegistrationService.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Security;
|
||||
using Oqtane.Shared;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Services
|
||||
{
|
||||
public class ServerEventRegistrationService : IEventRegistrationService
|
||||
{
|
||||
private readonly IEventRegistrationRepository _EventRegistrationRepository;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly Alias _alias;
|
||||
|
||||
public ServerEventRegistrationService(IEventRegistrationRepository EventRegistrationRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_EventRegistrationRepository = EventRegistrationRepository;
|
||||
_userPermissions = userPermissions;
|
||||
_logger = logger;
|
||||
_accessor = accessor;
|
||||
_alias = tenantManager.GetAlias();
|
||||
}
|
||||
|
||||
public Task<List<Models.Event>> GetEventRegistrationsAsync(int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_EventRegistrationRepository.GetEventRegistrations(ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
28
Server/Startup/ServerStartup.cs
Normal file
28
Server/Startup/ServerStartup.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oqtane.Infrastructure;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Repository;
|
||||
using SZUAbsolventenverein.Module.EventRegistration.Services;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.EventRegistration.Startup
|
||||
{
|
||||
public class ServerStartup : IServerStartup
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
public void ConfigureMvc(IMvcBuilder mvcBuilder)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IEventRegistrationService, ServerEventRegistrationService>();
|
||||
services.AddDbContextFactory<EventRegistrationContext>(opt => { }, ServiceLifetime.Transient);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
/* Module Custom Styles */
|
@ -0,0 +1,5 @@
|
||||
/* Module Script */
|
||||
var SZUAbsolventenverein = SZUAbsolventenverein || {};
|
||||
|
||||
SZUAbsolventenverein.EventRegistration = {
|
||||
};
|
11
Server/wwwroot/_content/Placeholder.txt
Normal file
11
Server/wwwroot/_content/Placeholder.txt
Normal file
@ -0,0 +1,11 @@
|
||||
The _content folder should only contain static resources from shared razor component libraries (RCLs). Static resources can be extracted from shared RCL Nuget packages by executing a Publish task on the module's Server project to a local folder and copying the files from the _content folder which is created. Each shared RCL would have its own appropriately named subfolder within the module's _content folder.
|
||||
|
||||
ie.
|
||||
|
||||
/_content
|
||||
/Radzen.Blazor
|
||||
/css
|
||||
/fonts
|
||||
/syncfusion.blazor
|
||||
/scripts
|
||||
/styles
|
Reference in New Issue
Block a user