This commit is contained in:
2020-03-25 16:02:15 +00:00
parent fb7fd98c91
commit 127d113f8f
2 changed files with 25 additions and 8 deletions

View File

@@ -59,20 +59,23 @@ namespace AyaNova.Biz
//
//put
internal async Task<bool> ReplaceAsync(GlobalBizSettings global)
internal async Task<bool> ReplaceAsync(GlobalBizSettings inObj)
{
var o = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (o == null)
var dbObj = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (dbObj == null)
throw new System.Exception("GlobalBizSettingsBiz::ReplaceAsync -> Global settings object not found in database!!");
CopyObject.Copy(global, o);
Validate(o);
CopyObject.Copy(inObj, dbObj, "Id");
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
Validate(dbObj);
if (HasErrors)
return false;
await ct.SaveChangesAsync();
//Log modification and save context
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 1, BizType, AyaEvent.Modified), ct);
//Update the static copy for the server
ServerGlobalBizSettings.Initialize(o);
ServerGlobalBizSettings.Initialize(dbObj);
return true;
}