
Interface Definition: done Server-Side-Implementation: partly done (CR missing, potential Refactor, ...) Client-Side-Implementation: started: (UI: done, Service: started, but works with SSR) Missing: Permissions / Roles to restrict access to an event. Missing: Fields on Event. Missing: Good Styling Time-Took: about 12 Hours. Learning: Commit in smaller packets, rest will be discussed at CR
92 lines
3.5 KiB
C#
92 lines
3.5 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.EventRegistration.Repository;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SZUAbsolventenverein.Module.EventRegistration.Manager
|
|
{
|
|
public class EventRegistrationManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
|
{
|
|
private readonly IEventRepository _EventRepository;
|
|
private readonly IResponseRepository _ResponseRepository;
|
|
private readonly IDBContextDependencies _DBContextDependencies;
|
|
|
|
public EventRegistrationManager(IEventRepository EventRegistrationRepository, IResponseRepository ResponseRepository, IDBContextDependencies DBContextDependencies)
|
|
{
|
|
_EventRepository = EventRegistrationRepository;
|
|
_ResponseRepository = ResponseRepository;
|
|
_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)
|
|
{
|
|
// TODO: Export event Responses as well.
|
|
string content = "";
|
|
List<Models.Event> EventRegistrations = _EventRepository.GetEvents(module.ModuleId).ToList();
|
|
if (EventRegistrations != null)
|
|
{
|
|
content = JsonSerializer.Serialize(EventRegistrations);
|
|
}
|
|
return content;
|
|
}
|
|
|
|
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
|
{
|
|
// TODO: Import event Responses as well.
|
|
List<Models.Event> EventRegistrations = null;
|
|
if (!string.IsNullOrEmpty(content))
|
|
{
|
|
EventRegistrations = JsonSerializer.Deserialize<List<Models.Event>>(content);
|
|
}
|
|
if (EventRegistrations != null)
|
|
{
|
|
foreach(var EventRegistration in EventRegistrations)
|
|
{
|
|
_EventRepository.AddEvent(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 _EventRepository.GetEvents(pageModule.ModuleId))
|
|
{
|
|
if (EventRegistration.ModifiedOn >= lastIndexedOn)
|
|
{
|
|
searchContentList.Add(new SearchContent
|
|
{
|
|
EntityName = "SZUAbsolventenvereinEventRegistration",
|
|
EntityId = EventRegistration.EventId.ToString(),
|
|
Title = EventRegistration.Name,
|
|
Body = EventRegistration.Name,
|
|
ContentModifiedBy = EventRegistration.ModifiedBy,
|
|
ContentModifiedOn = EventRegistration.ModifiedOn
|
|
});
|
|
}
|
|
}
|
|
|
|
return Task.FromResult(searchContentList);
|
|
}
|
|
}
|
|
}
|