mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
Making the configuration actually do something. Setting a default configuration if there is no DB
This commit is contained in:
parent
c49e9a386b
commit
f2399d6407
10 changed files with 171 additions and 75 deletions
|
@ -25,8 +25,10 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using Mono.Data.Sqlite;
|
||||
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Helpers;
|
||||
using PlexRequests.Store;
|
||||
using PlexRequests.Store.Repository;
|
||||
|
||||
namespace PlexRequests.Core
|
||||
{
|
||||
|
@ -36,9 +38,29 @@ namespace PlexRequests.Core
|
|||
public string SetupDb()
|
||||
{
|
||||
var db = new DbConfiguration(new SqliteFactory());
|
||||
db.CheckDb();
|
||||
var created = db.CheckDb();
|
||||
TableCreation.CreateTables(db.DbConnection());
|
||||
|
||||
if (created)
|
||||
{
|
||||
CreateDefaultSettingsPage();
|
||||
}
|
||||
|
||||
return db.DbConnection().ConnectionString;
|
||||
}
|
||||
|
||||
|
||||
private void CreateDefaultSettingsPage()
|
||||
{
|
||||
var defaultSettings = new PlexRequestSettings
|
||||
{
|
||||
RequireApproval = true,
|
||||
SearchForMovies = true,
|
||||
SearchForTvShows = true,
|
||||
WeeklyRequestLimit = 0
|
||||
};
|
||||
var s = new SettingsServiceV2<PlexRequestSettings>(new JsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||
s.SaveSettings(defaultSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue