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:
Shaun Walker
2019-08-14 09:34:35 -04:00
parent 916109015f
commit b71f007981
78 changed files with 809 additions and 261 deletions

View 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;
}
}
}
}