Initial commit
This commit is contained in:
4
Server/AssemblyInfo.cs
Normal file
4
Server/AssemblyInfo.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
using System.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
[assembly: RootNamespace("SZUAbsolventenverein.Module.PremiumArea.Server")]
|
||||
114
Server/Controllers/PremiumAreaController.cs
Normal file
114
Server/Controllers/PremiumAreaController.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.PremiumArea.Services;
|
||||
using Oqtane.Controllers;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Controllers
|
||||
{
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class PremiumAreaController : ModuleControllerBase
|
||||
{
|
||||
private readonly IPremiumAreaService _PremiumAreaService;
|
||||
|
||||
public PremiumAreaController(IPremiumAreaService PremiumAreaService, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor)
|
||||
{
|
||||
_PremiumAreaService = PremiumAreaService;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?moduleid=x
|
||||
[HttpGet]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<IEnumerable<Models.PremiumArea>> Get(string moduleid)
|
||||
{
|
||||
int ModuleId;
|
||||
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
||||
{
|
||||
return await _PremiumAreaService.GetPremiumAreasAsync(ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea 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.PremiumArea> Get(int id, int moduleid)
|
||||
{
|
||||
Models.PremiumArea PremiumArea = await _PremiumAreaService.GetPremiumAreaAsync(id, moduleid);
|
||||
if (PremiumArea != null && IsAuthorizedEntityId(EntityNames.Module, PremiumArea.ModuleId))
|
||||
{
|
||||
return PremiumArea;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Get Attempt {PremiumAreaId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task<Models.PremiumArea> Post([FromBody] Models.PremiumArea PremiumArea)
|
||||
{
|
||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, PremiumArea.ModuleId))
|
||||
{
|
||||
PremiumArea = await _PremiumAreaService.AddPremiumAreaAsync(PremiumArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Post Attempt {PremiumArea}", PremiumArea);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
PremiumArea = null;
|
||||
}
|
||||
return PremiumArea;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task<Models.PremiumArea> Put(int id, [FromBody] Models.PremiumArea PremiumArea)
|
||||
{
|
||||
if (ModelState.IsValid && PremiumArea.PremiumAreaId == id && IsAuthorizedEntityId(EntityNames.Module, PremiumArea.ModuleId))
|
||||
{
|
||||
PremiumArea = await _PremiumAreaService.UpdatePremiumAreaAsync(PremiumArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Put Attempt {PremiumArea}", PremiumArea);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
PremiumArea = null;
|
||||
}
|
||||
return PremiumArea;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}/{moduleid}")]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task Delete(int id, int moduleid)
|
||||
{
|
||||
Models.PremiumArea PremiumArea = await _PremiumAreaService.GetPremiumAreaAsync(id, moduleid);
|
||||
if (PremiumArea != null && IsAuthorizedEntityId(EntityNames.Module, PremiumArea.ModuleId))
|
||||
{
|
||||
await _PremiumAreaService.DeletePremiumAreaAsync(id, PremiumArea.ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Delete Attempt {PremiumAreaId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Server/Manager/PremiumAreaManager.cs
Normal file
87
Server/Manager/PremiumAreaManager.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.PremiumArea.Repository;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Manager
|
||||
{
|
||||
public class PremiumAreaManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
||||
{
|
||||
private readonly IPremiumAreaRepository _PremiumAreaRepository;
|
||||
private readonly IDBContextDependencies _DBContextDependencies;
|
||||
|
||||
public PremiumAreaManager(IPremiumAreaRepository PremiumAreaRepository, IDBContextDependencies DBContextDependencies)
|
||||
{
|
||||
_PremiumAreaRepository = PremiumAreaRepository;
|
||||
_DBContextDependencies = DBContextDependencies;
|
||||
}
|
||||
|
||||
public bool Install(Tenant tenant, string version)
|
||||
{
|
||||
return Migrate(new PremiumAreaContext(_DBContextDependencies), tenant, MigrationType.Up);
|
||||
}
|
||||
|
||||
public bool Uninstall(Tenant tenant)
|
||||
{
|
||||
return Migrate(new PremiumAreaContext(_DBContextDependencies), tenant, MigrationType.Down);
|
||||
}
|
||||
|
||||
public string ExportModule(Oqtane.Models.Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<Models.PremiumArea> PremiumAreas = _PremiumAreaRepository.GetPremiumAreas(module.ModuleId).ToList();
|
||||
if (PremiumAreas != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize(PremiumAreas);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
||||
{
|
||||
List<Models.PremiumArea> PremiumAreas = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
PremiumAreas = JsonSerializer.Deserialize<List<Models.PremiumArea>>(content);
|
||||
}
|
||||
if (PremiumAreas != null)
|
||||
{
|
||||
foreach(var PremiumArea in PremiumAreas)
|
||||
{
|
||||
_PremiumAreaRepository.AddPremiumArea(new Models.PremiumArea { ModuleId = module.ModuleId, Name = PremiumArea.Name });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<SearchContent>> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn)
|
||||
{
|
||||
var searchContentList = new List<SearchContent>();
|
||||
|
||||
foreach (var PremiumArea in _PremiumAreaRepository.GetPremiumAreas(pageModule.ModuleId))
|
||||
{
|
||||
if (PremiumArea.ModifiedOn >= lastIndexedOn)
|
||||
{
|
||||
searchContentList.Add(new SearchContent
|
||||
{
|
||||
EntityName = "SZUAbsolventenvereinPremiumArea",
|
||||
EntityId = PremiumArea.PremiumAreaId.ToString(),
|
||||
Title = PremiumArea.Name,
|
||||
Body = PremiumArea.Name,
|
||||
ContentModifiedBy = PremiumArea.ModifiedBy,
|
||||
ContentModifiedOn = PremiumArea.ModifiedOn
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(searchContentList);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Server/Migrations/01000000_InitializeModule.cs
Normal file
30
Server/Migrations/01000000_InitializeModule.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using SZUAbsolventenverein.Module.PremiumArea.Migrations.EntityBuilders;
|
||||
using SZUAbsolventenverein.Module.PremiumArea.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Migrations
|
||||
{
|
||||
[DbContext(typeof(PremiumAreaContext))]
|
||||
[Migration("SZUAbsolventenverein.Module.PremiumArea.01.00.00.00")]
|
||||
public class InitializeModule : MultiDatabaseMigration
|
||||
{
|
||||
public InitializeModule(IDatabase database) : base(database)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new PremiumAreaEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Create();
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new PremiumAreaEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Drop();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Server/Migrations/EntityBuilders/PremiumAreaEntityBuilder.cs
Normal file
36
Server/Migrations/EntityBuilders/PremiumAreaEntityBuilder.cs
Normal file
@@ -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.PremiumArea.Migrations.EntityBuilders
|
||||
{
|
||||
public class PremiumAreaEntityBuilder : AuditableBaseEntityBuilder<PremiumAreaEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SZUAbsolventenvereinPremiumArea";
|
||||
private readonly PrimaryKey<PremiumAreaEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinPremiumArea", x => x.PremiumAreaId);
|
||||
private readonly ForeignKey<PremiumAreaEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinPremiumArea_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||
|
||||
public PremiumAreaEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
ForeignKeys.Add(_moduleForeignKey);
|
||||
}
|
||||
|
||||
protected override PremiumAreaEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
PremiumAreaId = AddAutoIncrementColumn(table,"PremiumAreaId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
Name = AddMaxStringColumn(table,"Name");
|
||||
AddAuditableColumns(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> PremiumAreaId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||
}
|
||||
}
|
||||
26
Server/Repository/PremiumAreaContext.cs
Normal file
26
Server/Repository/PremiumAreaContext.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository.Databases.Interfaces;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Repository
|
||||
{
|
||||
public class PremiumAreaContext : DBContextBase, ITransientService, IMultiDatabase
|
||||
{
|
||||
public virtual DbSet<Models.PremiumArea> PremiumArea { get; set; }
|
||||
|
||||
public PremiumAreaContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<Models.PremiumArea>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinPremiumArea"));
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Server/Repository/PremiumAreaRepository.cs
Normal file
75
Server/Repository/PremiumAreaRepository.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Repository
|
||||
{
|
||||
public interface IPremiumAreaRepository
|
||||
{
|
||||
IEnumerable<Models.PremiumArea> GetPremiumAreas(int ModuleId);
|
||||
Models.PremiumArea GetPremiumArea(int PremiumAreaId);
|
||||
Models.PremiumArea GetPremiumArea(int PremiumAreaId, bool tracking);
|
||||
Models.PremiumArea AddPremiumArea(Models.PremiumArea PremiumArea);
|
||||
Models.PremiumArea UpdatePremiumArea(Models.PremiumArea PremiumArea);
|
||||
void DeletePremiumArea(int PremiumAreaId);
|
||||
}
|
||||
|
||||
public class PremiumAreaRepository : IPremiumAreaRepository, ITransientService
|
||||
{
|
||||
private readonly IDbContextFactory<PremiumAreaContext> _factory;
|
||||
|
||||
public PremiumAreaRepository(IDbContextFactory<PremiumAreaContext> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
public IEnumerable<Models.PremiumArea> GetPremiumAreas(int ModuleId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
return db.PremiumArea.Where(item => item.ModuleId == ModuleId).ToList();
|
||||
}
|
||||
|
||||
public Models.PremiumArea GetPremiumArea(int PremiumAreaId)
|
||||
{
|
||||
return GetPremiumArea(PremiumAreaId, true);
|
||||
}
|
||||
|
||||
public Models.PremiumArea GetPremiumArea(int PremiumAreaId, bool tracking)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
if (tracking)
|
||||
{
|
||||
return db.PremiumArea.Find(PremiumAreaId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.PremiumArea.AsNoTracking().FirstOrDefault(item => item.PremiumAreaId == PremiumAreaId);
|
||||
}
|
||||
}
|
||||
|
||||
public Models.PremiumArea AddPremiumArea(Models.PremiumArea PremiumArea)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.PremiumArea.Add(PremiumArea);
|
||||
db.SaveChanges();
|
||||
return PremiumArea;
|
||||
}
|
||||
|
||||
public Models.PremiumArea UpdatePremiumArea(Models.PremiumArea PremiumArea)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Entry(PremiumArea).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return PremiumArea;
|
||||
}
|
||||
|
||||
public void DeletePremiumArea(int PremiumAreaId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
Models.PremiumArea PremiumArea = db.PremiumArea.Find(PremiumAreaId);
|
||||
db.PremiumArea.Remove(PremiumArea);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Server/SZUAbsolventenverein.Module.PremiumArea.Server.csproj
Normal file
38
Server/SZUAbsolventenverein.Module.PremiumArea.Server.csproj
Normal file
@@ -0,0 +1,38 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
||||
<Version>1.0.0</Version>
|
||||
<Product>SZUAbsolventenverein.Module.PremiumArea</Product>
|
||||
<Authors>SZUAbsolventenverein</Authors>
|
||||
<Company>SZUAbsolventenverein</Company>
|
||||
<Description>This module adds a premium member system to Octane. Users receive premium status after completing a payment. Premium members get access to exclusive features and content.</Description>
|
||||
<Copyright>SZUAbsolventenverein</Copyright>
|
||||
<AssemblyName>SZUAbsolventenverein.Module.PremiumArea.Server.Oqtane</AssemblyName>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<StaticWebAssetsFingerprintContent>false</StaticWebAssetsFingerprintContent>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="wwwroot\_content\**\*.*" />
|
||||
<None Include="wwwroot\_content\**\*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Client\SZUAbsolventenverein.Module.PremiumArea.Client.csproj" />
|
||||
<ProjectReference Include="..\Shared\SZUAbsolventenverein.Module.PremiumArea.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Oqtane.Server"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Server.dll</HintPath></Reference>
|
||||
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
101
Server/Services/PremiumAreaService.cs
Normal file
101
Server/Services/PremiumAreaService.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.PremiumArea.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Services
|
||||
{
|
||||
public class ServerPremiumAreaService : IPremiumAreaService
|
||||
{
|
||||
private readonly IPremiumAreaRepository _PremiumAreaRepository;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly Alias _alias;
|
||||
|
||||
public ServerPremiumAreaService(IPremiumAreaRepository PremiumAreaRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_PremiumAreaRepository = PremiumAreaRepository;
|
||||
_userPermissions = userPermissions;
|
||||
_logger = logger;
|
||||
_accessor = accessor;
|
||||
_alias = tenantManager.GetAlias();
|
||||
}
|
||||
|
||||
public Task<List<Models.PremiumArea>> GetPremiumAreasAsync(int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_PremiumAreaRepository.GetPremiumAreas(ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Models.PremiumArea> GetPremiumAreaAsync(int PremiumAreaId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_PremiumAreaRepository.GetPremiumArea(PremiumAreaId));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Get Attempt {PremiumAreaId} {ModuleId}", PremiumAreaId, ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Models.PremiumArea> AddPremiumAreaAsync(Models.PremiumArea PremiumArea)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, PremiumArea.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
PremiumArea = _PremiumAreaRepository.AddPremiumArea(PremiumArea);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "PremiumArea Added {PremiumArea}", PremiumArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Add Attempt {PremiumArea}", PremiumArea);
|
||||
PremiumArea = null;
|
||||
}
|
||||
return Task.FromResult(PremiumArea);
|
||||
}
|
||||
|
||||
public Task<Models.PremiumArea> UpdatePremiumAreaAsync(Models.PremiumArea PremiumArea)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, PremiumArea.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
PremiumArea = _PremiumAreaRepository.UpdatePremiumArea(PremiumArea);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "PremiumArea Updated {PremiumArea}", PremiumArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Update Attempt {PremiumArea}", PremiumArea);
|
||||
PremiumArea = null;
|
||||
}
|
||||
return Task.FromResult(PremiumArea);
|
||||
}
|
||||
|
||||
public Task DeletePremiumAreaAsync(int PremiumAreaId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
_PremiumAreaRepository.DeletePremiumArea(PremiumAreaId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "PremiumArea Deleted {PremiumAreaId}", PremiumAreaId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized PremiumArea Delete Attempt {PremiumAreaId} {ModuleId}", PremiumAreaId, 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.PremiumArea.Repository;
|
||||
using SZUAbsolventenverein.Module.PremiumArea.Services;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.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<IPremiumAreaService, ServerPremiumAreaService>();
|
||||
services.AddDbContextFactory<PremiumAreaContext>(opt => { }, ServiceLifetime.Transient);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Server/wwwroot/Module.css
Normal file
1
Server/wwwroot/Module.css
Normal file
@@ -0,0 +1 @@
|
||||
/* Module Custom Styles */
|
||||
5
Server/wwwroot/Module.js
Normal file
5
Server/wwwroot/Module.js
Normal file
@@ -0,0 +1,5 @@
|
||||
/* Module Script */
|
||||
var SZUAbsolventenverein = SZUAbsolventenverein || {};
|
||||
|
||||
SZUAbsolventenverein.PremiumArea = {
|
||||
};
|
||||
Reference in New Issue
Block a user