From 182a156bd8db76189bc9a744cd169026a488f3af Mon Sep 17 00:00:00 2001 From: Emanuele Filardo Date: Fri, 20 Sep 2019 17:51:13 +0200 Subject: [PATCH] Improved to skip new Added entities and if softdelete properties are unmodified --- Oqtane.Server/Repository/Context/DBContextBase.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Oqtane.Server/Repository/Context/DBContextBase.cs b/Oqtane.Server/Repository/Context/DBContextBase.cs index 587f078e..20e3254e 100644 --- a/Oqtane.Server/Repository/Context/DBContextBase.cs +++ b/Oqtane.Server/Repository/Context/DBContextBase.cs @@ -71,14 +71,16 @@ namespace Oqtane.Repository item.CurrentValues[nameof(IAuditable.ModifiedOn)] = date; } - if (item.Entity is ISoftDeletable softDeleted) + if (item.Entity is ISoftDeletable softDeleted && item.State != EntityState.Added) { - if ((bool)item.CurrentValues[nameof(ISoftDeletable.IsSoftDeleted)]) + if ((bool)item.CurrentValues[nameof(ISoftDeletable.IsSoftDeleted)] + && !item.GetDatabaseValues().GetValue(nameof(ISoftDeletable.IsSoftDeleted))) { item.CurrentValues[nameof(ISoftDeletable.DeletedBy)] = username; item.CurrentValues[nameof(ISoftDeletable.DeletedOn)] = date; } - else + else if (!(bool)item.CurrentValues[nameof(ISoftDeletable.IsSoftDeleted)] + && item.GetDatabaseValues().GetValue(nameof(ISoftDeletable.IsSoftDeleted))) { item.CurrentValues[nameof(ISoftDeletable.DeletedBy)] = null; item.CurrentValues[nameof(ISoftDeletable.DeletedOn)] = null;