Add the Issue Reporting functionality (#1811)

* Added issuesreporting and the ability to add categories to the UI
* Added lazy loading!
This commit is contained in:
Jamie 2017-12-28 21:51:33 +00:00 committed by GitHub
parent 438f56eceb
commit 246f1c07cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 2905 additions and 526 deletions

View file

@ -5,7 +5,6 @@ using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Microsoft.Extensions.Caching.Memory;
namespace Ombi.Settings.Settings
{
@ -13,7 +12,7 @@ namespace Ombi.Settings.Settings
where T : Models.Settings, new()
{
public SettingsService(ISettingsRepository repo, IMemoryCache cache)
public SettingsService(ISettingsRepository repo, ICacheService cache)
{
Repo = repo;
EntityName = typeof(T).Name;
@ -23,13 +22,12 @@ namespace Ombi.Settings.Settings
private ISettingsRepository Repo { get; }
private string EntityName { get; }
private string CacheName => $"Settings{EntityName}";
private readonly IMemoryCache _cache;
private readonly ICacheService _cache;
public T GetSettings()
{
return _cache.GetOrCreate(CacheName, entry =>
return _cache.GetOrAdd(CacheName, () =>
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(2);
var result = Repo.Get(EntityName);
if (result == null)
{
@ -43,14 +41,13 @@ namespace Ombi.Settings.Settings
var model = obj;
return model;
});
}, DateTime.Now.AddHours(2));
}
public async Task<T> GetSettingsAsync()
{
return await _cache.GetOrCreateAsync(CacheName, async entry =>
return await _cache.GetOrAdd(CacheName, async () =>
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(2);
var result = await Repo.GetAsync(EntityName);
if (result == null)
{
@ -64,7 +61,7 @@ namespace Ombi.Settings.Settings
var model = obj;
return model;
});
}, DateTime.Now.AddHours(2));
}
public bool SaveSettings(T model)