Support for third party modules, improved error handling, standardardized enum naming, reorganized interface definitions, support for DB script upgrades, added Settings entity
This commit is contained in:
@ -12,6 +12,7 @@ namespace Oqtane.Repository
|
||||
public virtual DbSet<Module> Module { get; set; }
|
||||
public virtual DbSet<User> User { get; set; }
|
||||
public virtual DbSet<SiteUser> SiteUser { get; set; }
|
||||
public virtual DbSet<Setting> Setting { get; set; }
|
||||
|
||||
public TenantDBContext(ITenantResolver TenantResolver, IHttpContextAccessor accessor) : base(TenantResolver, accessor)
|
||||
{
|
14
Oqtane.Server/Repository/Interfaces/ISettingRepository.cs
Normal file
14
Oqtane.Server/Repository/Interfaces/ISettingRepository.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface ISettingRepository
|
||||
{
|
||||
IEnumerable<Setting> GetSettings(string EntityName, int EntityId);
|
||||
Setting AddSetting(Setting Setting);
|
||||
Setting UpdateSetting(Setting Setting);
|
||||
Setting GetSetting(int SettingId);
|
||||
void DeleteSetting(int SettingId);
|
||||
}
|
||||
}
|
@ -22,12 +22,11 @@ namespace Oqtane.Repository
|
||||
List<ModuleDefinition> moduledefinitions = new List<ModuleDefinition>();
|
||||
|
||||
// iterate through Oqtane module assemblies
|
||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.Where(item => item.FullName.StartsWith("Oqtane.") || item.FullName.Contains(".Module.")).ToArray();
|
||||
foreach (Assembly assembly in assemblies)
|
||||
{
|
||||
if (assembly.FullName.StartsWith("Oqtane.Client") || assembly.FullName.StartsWith("Oqtane.Module."))
|
||||
{
|
||||
moduledefinitions = LoadModuleDefinitionsFromAssembly(moduledefinitions, assembly);
|
||||
}
|
||||
moduledefinitions = LoadModuleDefinitionsFromAssembly(moduledefinitions, assembly);
|
||||
}
|
||||
|
||||
return moduledefinitions;
|
||||
@ -119,6 +118,5 @@ namespace Oqtane.Repository
|
||||
return moduledefinitions;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
85
Oqtane.Server/Repository/SettingRepository.cs
Normal file
85
Oqtane.Server/Repository/SettingRepository.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class SettingRepository : ISettingRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
|
||||
public SettingRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Setting> GetSettings(string EntityName, int EntityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return db.Setting.Where(item => item.EntityName == EntityName)
|
||||
.Where(item => item.EntityId == EntityId).ToList();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Setting AddSetting(Setting Setting)
|
||||
{
|
||||
try
|
||||
{
|
||||
db.Setting.Add(Setting);
|
||||
db.SaveChanges();
|
||||
return Setting;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Setting UpdateSetting(Setting Setting)
|
||||
{
|
||||
try
|
||||
{
|
||||
db.Entry(Setting).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return Setting;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Setting GetSetting(int SettingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Setting Setting = db.Setting.Find(SettingId);
|
||||
return Setting;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteSetting(int SettingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Setting Setting = db.Setting.Find(SettingId);
|
||||
db.Setting.Remove(Setting);
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,13 +22,11 @@ namespace Oqtane.Repository
|
||||
List<Theme> themes = new List<Theme>();
|
||||
|
||||
// iterate through Oqtane theme assemblies
|
||||
// TODO: Remove restriction on assembly
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.Where(item => item.FullName.StartsWith("Oqtane.") || item.FullName.Contains(".Theme.")).ToArray();
|
||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (assembly.FullName.StartsWith("Oqtane.Client") || assembly.FullName.StartsWith("Oqtane.Theme."))
|
||||
{
|
||||
themes = LoadThemesFromAssembly(themes, assembly);
|
||||
}
|
||||
themes = LoadThemesFromAssembly(themes, assembly);
|
||||
}
|
||||
|
||||
return themes;
|
||||
|
Reference in New Issue
Block a user