88 lines
3.2 KiB
C#
88 lines
3.2 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|