Initial Commit: BlackBoard inkl. Reporting
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.BlackBoard.Server")]
|
||||
114
Server/Controllers/BlackBoardController.cs
Normal file
114
Server/Controllers/BlackBoardController.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.BlackBoard.Services;
|
||||
using Oqtane.Controllers;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.BlackBoard.Controllers
|
||||
{
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class BlackBoardController : ModuleControllerBase
|
||||
{
|
||||
private readonly IBlackBoardService _BlackBoardService;
|
||||
|
||||
public BlackBoardController(IBlackBoardService BlackBoardService, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor)
|
||||
{
|
||||
_BlackBoardService = BlackBoardService;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?moduleid=x
|
||||
[HttpGet]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public async Task<IEnumerable<Models.BlackBoard>> Get(string moduleid)
|
||||
{
|
||||
int ModuleId;
|
||||
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
||||
{
|
||||
return await _BlackBoardService.GetBlackBoardsAsync(ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard 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.BlackBoard> Get(int id, int moduleid)
|
||||
{
|
||||
Models.BlackBoard BlackBoard = await _BlackBoardService.GetBlackBoardAsync(id, moduleid);
|
||||
if (BlackBoard != null && IsAuthorizedEntityId(EntityNames.Module, BlackBoard.ModuleId))
|
||||
{
|
||||
return BlackBoard;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Get Attempt {BlackBoardId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task<Models.BlackBoard> Post([FromBody] Models.BlackBoard BlackBoard)
|
||||
{
|
||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, BlackBoard.ModuleId))
|
||||
{
|
||||
BlackBoard = await _BlackBoardService.AddBlackBoardAsync(BlackBoard);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Post Attempt {BlackBoard}", BlackBoard);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
BlackBoard = null;
|
||||
}
|
||||
return BlackBoard;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task<Models.BlackBoard> Put(int id, [FromBody] Models.BlackBoard BlackBoard)
|
||||
{
|
||||
if (ModelState.IsValid && BlackBoard.BlackBoardId == id && IsAuthorizedEntityId(EntityNames.Module, BlackBoard.ModuleId))
|
||||
{
|
||||
BlackBoard = await _BlackBoardService.UpdateBlackBoardAsync(BlackBoard);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Put Attempt {BlackBoard}", BlackBoard);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
BlackBoard = null;
|
||||
}
|
||||
return BlackBoard;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}/{moduleid}")]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public async Task Delete(int id, int moduleid)
|
||||
{
|
||||
Models.BlackBoard BlackBoard = await _BlackBoardService.GetBlackBoardAsync(id, moduleid);
|
||||
if (BlackBoard != null && IsAuthorizedEntityId(EntityNames.Module, BlackBoard.ModuleId))
|
||||
{
|
||||
await _BlackBoardService.DeleteBlackBoardAsync(id, BlackBoard.ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Delete Attempt {BlackBoardId} {ModuleId}", id, moduleid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Server/Manager/BlackBoardManager.cs
Normal file
87
Server/Manager/BlackBoardManager.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.BlackBoard.Repository;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.BlackBoard.Manager
|
||||
{
|
||||
public class BlackBoardManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
||||
{
|
||||
private readonly IBlackBoardRepository _BlackBoardRepository;
|
||||
private readonly IDBContextDependencies _DBContextDependencies;
|
||||
|
||||
public BlackBoardManager(IBlackBoardRepository BlackBoardRepository, IDBContextDependencies DBContextDependencies)
|
||||
{
|
||||
_BlackBoardRepository = BlackBoardRepository;
|
||||
_DBContextDependencies = DBContextDependencies;
|
||||
}
|
||||
|
||||
public bool Install(Tenant tenant, string version)
|
||||
{
|
||||
return Migrate(new BlackBoardContext(_DBContextDependencies), tenant, MigrationType.Up);
|
||||
}
|
||||
|
||||
public bool Uninstall(Tenant tenant)
|
||||
{
|
||||
return Migrate(new BlackBoardContext(_DBContextDependencies), tenant, MigrationType.Down);
|
||||
}
|
||||
|
||||
public string ExportModule(Oqtane.Models.Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<Models.BlackBoard> BlackBoards = _BlackBoardRepository.GetBlackBoards(module.ModuleId).ToList();
|
||||
if (BlackBoards != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize(BlackBoards);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
||||
{
|
||||
List<Models.BlackBoard> BlackBoards = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
BlackBoards = JsonSerializer.Deserialize<List<Models.BlackBoard>>(content);
|
||||
}
|
||||
if (BlackBoards != null)
|
||||
{
|
||||
foreach(var BlackBoard in BlackBoards)
|
||||
{
|
||||
_BlackBoardRepository.AddBlackBoard(new Models.BlackBoard { ModuleId = module.ModuleId, Name = BlackBoard.Name });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<SearchContent>> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn)
|
||||
{
|
||||
var searchContentList = new List<SearchContent>();
|
||||
|
||||
foreach (var BlackBoard in _BlackBoardRepository.GetBlackBoards(pageModule.ModuleId))
|
||||
{
|
||||
if (BlackBoard.ModifiedOn >= lastIndexedOn)
|
||||
{
|
||||
searchContentList.Add(new SearchContent
|
||||
{
|
||||
EntityName = "SZUAbsolventenvereinBlackBoard",
|
||||
EntityId = BlackBoard.BlackBoardId.ToString(),
|
||||
Title = BlackBoard.Name,
|
||||
Body = BlackBoard.Name,
|
||||
ContentModifiedBy = BlackBoard.ModifiedBy,
|
||||
ContentModifiedOn = BlackBoard.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.BlackBoard.Migrations.EntityBuilders;
|
||||
using SZUAbsolventenverein.Module.BlackBoard.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.BlackBoard.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlackBoardContext))]
|
||||
[Migration("SZUAbsolventenverein.Module.BlackBoard.01.00.00.00")]
|
||||
public class InitializeModule : MultiDatabaseMigration
|
||||
{
|
||||
public InitializeModule(IDatabase database) : base(database)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new BlackBoardEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Create();
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var entityBuilder = new BlackBoardEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Drop();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Server/Migrations/EntityBuilders/BlackBoardEntityBuilder.cs
Normal file
36
Server/Migrations/EntityBuilders/BlackBoardEntityBuilder.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.BlackBoard.Migrations.EntityBuilders
|
||||
{
|
||||
public class BlackBoardEntityBuilder : AuditableBaseEntityBuilder<BlackBoardEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SZUAbsolventenvereinBlackBoard";
|
||||
private readonly PrimaryKey<BlackBoardEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinBlackBoard", x => x.BlackBoardId);
|
||||
private readonly ForeignKey<BlackBoardEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinBlackBoard_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||
|
||||
public BlackBoardEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
ForeignKeys.Add(_moduleForeignKey);
|
||||
}
|
||||
|
||||
protected override BlackBoardEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
BlackBoardId = AddAutoIncrementColumn(table,"BlackBoardId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
Name = AddMaxStringColumn(table,"Name");
|
||||
AddAuditableColumns(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> BlackBoardId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||
}
|
||||
}
|
||||
26
Server/Repository/BlackBoardContext.cs
Normal file
26
Server/Repository/BlackBoardContext.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.BlackBoard.Repository
|
||||
{
|
||||
public class BlackBoardContext : DBContextBase, ITransientService, IMultiDatabase
|
||||
{
|
||||
public virtual DbSet<Models.BlackBoard> BlackBoard { get; set; }
|
||||
|
||||
public BlackBoardContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<Models.BlackBoard>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinBlackBoard"));
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Server/Repository/BlackBoardRepository.cs
Normal file
75
Server/Repository/BlackBoardRepository.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.BlackBoard.Repository
|
||||
{
|
||||
public interface IBlackBoardRepository
|
||||
{
|
||||
IEnumerable<Models.BlackBoard> GetBlackBoards(int ModuleId);
|
||||
Models.BlackBoard GetBlackBoard(int BlackBoardId);
|
||||
Models.BlackBoard GetBlackBoard(int BlackBoardId, bool tracking);
|
||||
Models.BlackBoard AddBlackBoard(Models.BlackBoard BlackBoard);
|
||||
Models.BlackBoard UpdateBlackBoard(Models.BlackBoard BlackBoard);
|
||||
void DeleteBlackBoard(int BlackBoardId);
|
||||
}
|
||||
|
||||
public class BlackBoardRepository : IBlackBoardRepository, ITransientService
|
||||
{
|
||||
private readonly IDbContextFactory<BlackBoardContext> _factory;
|
||||
|
||||
public BlackBoardRepository(IDbContextFactory<BlackBoardContext> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
public IEnumerable<Models.BlackBoard> GetBlackBoards(int ModuleId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
return db.BlackBoard.Where(item => item.ModuleId == ModuleId).ToList();
|
||||
}
|
||||
|
||||
public Models.BlackBoard GetBlackBoard(int BlackBoardId)
|
||||
{
|
||||
return GetBlackBoard(BlackBoardId, true);
|
||||
}
|
||||
|
||||
public Models.BlackBoard GetBlackBoard(int BlackBoardId, bool tracking)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
if (tracking)
|
||||
{
|
||||
return db.BlackBoard.Find(BlackBoardId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.BlackBoard.AsNoTracking().FirstOrDefault(item => item.BlackBoardId == BlackBoardId);
|
||||
}
|
||||
}
|
||||
|
||||
public Models.BlackBoard AddBlackBoard(Models.BlackBoard BlackBoard)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.BlackBoard.Add(BlackBoard);
|
||||
db.SaveChanges();
|
||||
return BlackBoard;
|
||||
}
|
||||
|
||||
public Models.BlackBoard UpdateBlackBoard(Models.BlackBoard BlackBoard)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Entry(BlackBoard).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return BlackBoard;
|
||||
}
|
||||
|
||||
public void DeleteBlackBoard(int BlackBoardId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
Models.BlackBoard BlackBoard = db.BlackBoard.Find(BlackBoardId);
|
||||
db.BlackBoard.Remove(BlackBoard);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Server/SZUAbsolventenverein.Module.BlackBoard.Server.csproj
Normal file
38
Server/SZUAbsolventenverein.Module.BlackBoard.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.BlackBoard</Product>
|
||||
<Authors>SZUAbsolventenverein</Authors>
|
||||
<Company>SZUAbsolventenverein</Company>
|
||||
<Description>Kommunikationsplatform</Description>
|
||||
<Copyright>SZUAbsolventenverein</Copyright>
|
||||
<AssemblyName>SZUAbsolventenverein.Module.BlackBoard.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.BlackBoard.Client.csproj" />
|
||||
<ProjectReference Include="..\Shared\SZUAbsolventenverein.Module.BlackBoard.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/BlackBoardService.cs
Normal file
101
Server/Services/BlackBoardService.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.BlackBoard.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.BlackBoard.Services
|
||||
{
|
||||
public class ServerBlackBoardService : IBlackBoardService
|
||||
{
|
||||
private readonly IBlackBoardRepository _BlackBoardRepository;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly Alias _alias;
|
||||
|
||||
public ServerBlackBoardService(IBlackBoardRepository BlackBoardRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_BlackBoardRepository = BlackBoardRepository;
|
||||
_userPermissions = userPermissions;
|
||||
_logger = logger;
|
||||
_accessor = accessor;
|
||||
_alias = tenantManager.GetAlias();
|
||||
}
|
||||
|
||||
public Task<List<Models.BlackBoard>> GetBlackBoardsAsync(int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_BlackBoardRepository.GetBlackBoards(ModuleId).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Get Attempt {ModuleId}", ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Models.BlackBoard> GetBlackBoardAsync(int BlackBoardId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||
{
|
||||
return Task.FromResult(_BlackBoardRepository.GetBlackBoard(BlackBoardId));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Get Attempt {BlackBoardId} {ModuleId}", BlackBoardId, ModuleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Models.BlackBoard> AddBlackBoardAsync(Models.BlackBoard BlackBoard)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, BlackBoard.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
BlackBoard = _BlackBoardRepository.AddBlackBoard(BlackBoard);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "BlackBoard Added {BlackBoard}", BlackBoard);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Add Attempt {BlackBoard}", BlackBoard);
|
||||
BlackBoard = null;
|
||||
}
|
||||
return Task.FromResult(BlackBoard);
|
||||
}
|
||||
|
||||
public Task<Models.BlackBoard> UpdateBlackBoardAsync(Models.BlackBoard BlackBoard)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, BlackBoard.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
BlackBoard = _BlackBoardRepository.UpdateBlackBoard(BlackBoard);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "BlackBoard Updated {BlackBoard}", BlackBoard);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Update Attempt {BlackBoard}", BlackBoard);
|
||||
BlackBoard = null;
|
||||
}
|
||||
return Task.FromResult(BlackBoard);
|
||||
}
|
||||
|
||||
public Task DeleteBlackBoardAsync(int BlackBoardId, int ModuleId)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
_BlackBoardRepository.DeleteBlackBoard(BlackBoardId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "BlackBoard Deleted {BlackBoardId}", BlackBoardId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized BlackBoard Delete Attempt {BlackBoardId} {ModuleId}", BlackBoardId, 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.BlackBoard.Repository;
|
||||
using SZUAbsolventenverein.Module.BlackBoard.Services;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.BlackBoard.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<IBlackBoardService, ServerBlackBoardService>();
|
||||
services.AddDbContextFactory<BlackBoardContext>(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.BlackBoard = {
|
||||
};
|
||||
Reference in New Issue
Block a user