From ef99cc404ec15f76ab66207878c505ab95185036 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 22 May 2020 13:28:39 +0000 Subject: [PATCH] --- server/AyaNova/biz/GlobalBizSettingsBiz.cs | 11 ++++++++++- server/AyaNova/biz/GlobalOpsBackupSettingsBiz.cs | 14 ++++++++++++-- server/AyaNova/models/GlobalOpsBackupSettings.cs | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/server/AyaNova/biz/GlobalBizSettingsBiz.cs b/server/AyaNova/biz/GlobalBizSettingsBiz.cs index ae1b1f09..69f87784 100644 --- a/server/AyaNova/biz/GlobalBizSettingsBiz.cs +++ b/server/AyaNova/biz/GlobalBizSettingsBiz.cs @@ -71,7 +71,16 @@ namespace AyaNova.Biz Validate(dbObject); if (HasErrors) return null; - await ct.SaveChangesAsync(); + + try + { + await ct.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + AddError(ApiErrorCode.CONCURRENCY_CONFLICT); + return null; + } //Log modification and save context await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 1, BizType, AyaEvent.Modified), ct); //Update the static copy for the server diff --git a/server/AyaNova/biz/GlobalOpsBackupSettingsBiz.cs b/server/AyaNova/biz/GlobalOpsBackupSettingsBiz.cs index e495c142..e7157c0f 100644 --- a/server/AyaNova/biz/GlobalOpsBackupSettingsBiz.cs +++ b/server/AyaNova/biz/GlobalOpsBackupSettingsBiz.cs @@ -74,10 +74,20 @@ namespace AyaNova.Biz Validate(dbObject); if (HasErrors) return null; - await ct.SaveChangesAsync(); + + try + { + await ct.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + AddError(ApiErrorCode.CONCURRENCY_CONFLICT); + return null; + } + await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 1, BizType, AyaEvent.Modified), ct); //Update the static copy for the server - ServerGlobalOpsSettingsCache.Backup=dbObject; + ServerGlobalOpsSettingsCache.Backup = dbObject; return dbObject; } diff --git a/server/AyaNova/models/GlobalOpsBackupSettings.cs b/server/AyaNova/models/GlobalOpsBackupSettings.cs index 39cf677c..53fe0471 100644 --- a/server/AyaNova/models/GlobalOpsBackupSettings.cs +++ b/server/AyaNova/models/GlobalOpsBackupSettings.cs @@ -15,7 +15,7 @@ namespace AyaNova.Models public GlobalOpsBackupSettings() { Id = 1;//always 1 - BackupTime = new DateTime(2020, 5, 19, 23, 59, 0, DateTimeKind.Utc);//date doesn't matter it only uses hour + BackupTime = new DateTime(2020, 5, 19, 23, 59, 0, DateTimeKind.Local).ToUniversalTime();//date doesn't matter it only uses hour LastBackup = DateTime.MinValue; BackupSetsToKeep = 3;