mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
removed additional namespace
This commit is contained in:
parent
f9cbf18233
commit
3ea9be94aa
3 changed files with 71 additions and 78 deletions
|
@ -36,84 +36,79 @@ using RequestPlex.Store.Models;
|
|||
|
||||
namespace RequestPlex.Store.Repository
|
||||
{
|
||||
|
||||
|
||||
namespace NZBDash.DataAccessLayer.Repository
|
||||
public class JsonRepository : ISettingsRepository
|
||||
{
|
||||
public class JsonRepository : ISettingsRepository
|
||||
private ICacheProvider Cache { get; set; }
|
||||
|
||||
private string TypeName { get; set; }
|
||||
public JsonRepository(ISqliteConfiguration config, ICacheProvider cacheProvider)
|
||||
{
|
||||
private ICacheProvider Cache { get; set; }
|
||||
Db = config;
|
||||
Cache = cacheProvider;
|
||||
TypeName = typeof(JsonRepository).Name;
|
||||
}
|
||||
|
||||
private string TypeName { get; set; }
|
||||
public JsonRepository(ISqliteConfiguration config, ICacheProvider cacheProvider)
|
||||
private ISqliteConfiguration Db { get; set; }
|
||||
|
||||
public long Insert(GlobalSettings entity)
|
||||
{
|
||||
ResetCache();
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
Db = config;
|
||||
Cache = cacheProvider;
|
||||
TypeName = typeof(JsonRepository).Name;
|
||||
}
|
||||
|
||||
private ISqliteConfiguration Db { get; set; }
|
||||
|
||||
public long Insert(GlobalSettings entity)
|
||||
{
|
||||
ResetCache();
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
return con.Insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<GlobalSettings> GetAll()
|
||||
{
|
||||
var key = TypeName + "GetAll";
|
||||
var item = Cache.GetOrSet(key, () =>
|
||||
{
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
var page = con.GetAll<GlobalSettings>();
|
||||
return page;
|
||||
}
|
||||
}, 5);
|
||||
return item;
|
||||
}
|
||||
|
||||
public GlobalSettings Get(string pageName)
|
||||
{
|
||||
var key = pageName + "Get";
|
||||
var item = Cache.GetOrSet(key, () =>
|
||||
{
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
var page = con.GetAll<GlobalSettings>().SingleOrDefault(x => x.SettingsName == pageName);
|
||||
return page;
|
||||
}
|
||||
}, 5);
|
||||
return item;
|
||||
}
|
||||
|
||||
public bool Delete(GlobalSettings entity)
|
||||
{
|
||||
ResetCache();
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
return con.Delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update(GlobalSettings entity)
|
||||
{
|
||||
ResetCache();
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
return con.Update(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetCache()
|
||||
{
|
||||
Cache.Remove("Get");
|
||||
Cache.Remove(TypeName + "GetAll");
|
||||
return con.Insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<GlobalSettings> GetAll()
|
||||
{
|
||||
var key = TypeName + "GetAll";
|
||||
var item = Cache.GetOrSet(key, () =>
|
||||
{
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
var page = con.GetAll<GlobalSettings>();
|
||||
return page;
|
||||
}
|
||||
}, 5);
|
||||
return item;
|
||||
}
|
||||
|
||||
public GlobalSettings Get(string pageName)
|
||||
{
|
||||
var key = pageName + "Get";
|
||||
var item = Cache.GetOrSet(key, () =>
|
||||
{
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
var page = con.GetAll<GlobalSettings>().SingleOrDefault(x => x.SettingsName == pageName);
|
||||
return page;
|
||||
}
|
||||
}, 5);
|
||||
return item;
|
||||
}
|
||||
|
||||
public bool Delete(GlobalSettings entity)
|
||||
{
|
||||
ResetCache();
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
return con.Delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update(GlobalSettings entity)
|
||||
{
|
||||
ResetCache();
|
||||
using (var con = Db.DbConnection())
|
||||
{
|
||||
return con.Update(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetCache()
|
||||
{
|
||||
Cache.Remove("Get");
|
||||
Cache.Remove(TypeName + "GetAll");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ using RequestPlex.Core;
|
|||
using RequestPlex.Core.SettingModels;
|
||||
using RequestPlex.Helpers;
|
||||
using RequestPlex.Store;
|
||||
using RequestPlex.Store.Models;
|
||||
using RequestPlex.Store.Repository.NZBDash.DataAccessLayer.Repository;
|
||||
using RequestPlex.Store.Repository;
|
||||
|
||||
using FormsAuthentication = Nancy.Authentication.Forms.FormsAuthentication;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Owin.Hosting;
|
||||
|
||||
using Mono.Data.Sqlite;
|
||||
|
@ -8,7 +7,7 @@ using RequestPlex.Core;
|
|||
using RequestPlex.Core.SettingModels;
|
||||
using RequestPlex.Helpers;
|
||||
using RequestPlex.Store;
|
||||
using RequestPlex.Store.Repository.NZBDash.DataAccessLayer.Repository;
|
||||
using RequestPlex.Store.Repository;
|
||||
|
||||
namespace RequestPlex.UI
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue