This commit is contained in:
2020-05-21 23:58:57 +00:00
parent 4de095ca4e
commit 9d3986224c
5 changed files with 29 additions and 41 deletions

View File

@@ -59,24 +59,24 @@ namespace AyaNova.Biz
//
//put
internal async Task<bool> ReplaceAsync(GlobalBizSettings inObj)
internal async Task<GlobalBizSettings> PutAsync(GlobalBizSettings updatedObject)
{
var dbObj = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (dbObj == null)
var dbObject = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (dbObject == null)
throw new System.Exception("GlobalBizSettingsBiz::ReplaceAsync -> Global settings object not found in database!!");
CopyObject.Copy(inObj, dbObj, "Id");
CopyObject.Copy(updatedObject, dbObject, "Id");
ct.Entry(dbObj).OriginalValues["Concurrency"] = inObj.Concurrency;
ct.Entry(dbObject).OriginalValues["Concurrency"] = updatedObject.Concurrency;
Validate(dbObj);
Validate(dbObject);
if (HasErrors)
return false;
return null;
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(dbObj);
return true;
ServerGlobalBizSettings.Initialize(dbObject);
return dbObject;
}