diff --git a/RequestPlex.Store/Repository/JsonRepository.cs b/RequestPlex.Store/Repository/JsonRepository.cs index 4123aadc0..94dddf511 100644 --- a/RequestPlex.Store/Repository/JsonRepository.cs +++ b/RequestPlex.Store/Repository/JsonRepository.cs @@ -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 GetAll() - { - var key = TypeName + "GetAll"; - var item = Cache.GetOrSet(key, () => - { - using (var con = Db.DbConnection()) - { - var page = con.GetAll(); - 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().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 GetAll() + { + var key = TypeName + "GetAll"; + var item = Cache.GetOrSet(key, () => + { + using (var con = Db.DbConnection()) + { + var page = con.GetAll(); + 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().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"); + } } -} \ No newline at end of file +} diff --git a/RequestPlex.UI/Bootstrapper.cs b/RequestPlex.UI/Bootstrapper.cs index c73cf0b1a..d47f8f85b 100644 --- a/RequestPlex.UI/Bootstrapper.cs +++ b/RequestPlex.UI/Bootstrapper.cs @@ -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; diff --git a/RequestPlex.UI/Program.cs b/RequestPlex.UI/Program.cs index 5f24c7767..aac9df24c 100644 --- a/RequestPlex.UI/Program.cs +++ b/RequestPlex.UI/Program.cs @@ -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 {