Initial Commit: BlackBoard inkl. Reporting
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user