Add project files.
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user