Saving
This commit is contained in:
1 parent
9719a0c0fd
commit
1e66851113
146 files changed
+738
-382
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using MongoDB.Entities;
|
||||
|
||||
using PrivaPub.Models;
|
||||
using PrivaPub.StaticServices;
|
||||
|
||||
namespace PrivaPub.Services
|
||||
{
|
||||
public class AppConfigurationService
|
||||
{
|
||||
public AppConfiguration AppConfiguration;
|
||||
readonly DbEntities _dbEntities;
|
||||
AppConfiguration _appConfigurationFromFile;
|
||||
public AppConfigurationService(DbEntities dbEntities, IOptionsMonitor<AppConfiguration> appConfiguration)
|
||||
{
|
||||
_dbEntities = dbEntities;
|
||||
_appConfigurationFromFile = appConfiguration.CurrentValue;
|
||||
}
|
||||
|
||||
public async Task Init()
|
||||
{
|
||||
var dbAppConfiguration = await _dbEntities.AppConfiguration.ExecuteFirstAsync();
|
||||
if (dbAppConfiguration != default)
|
||||
{
|
||||
if (AppConfiguration == default || AppConfiguration.LastUpdateDate != dbAppConfiguration.LastUpdateDate)
|
||||
AppConfiguration = dbAppConfiguration;
|
||||
return;
|
||||
}
|
||||
|
||||
dbAppConfiguration = _appConfigurationFromFile;
|
||||
await dbAppConfiguration.SaveAsync();
|
||||
AppConfiguration = dbAppConfiguration;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user