Add basic support for SoftDeletable

This commit is contained in:
Emanuele Filardo 2019-09-19 16:52:47 +02:00
parent 4ccca043cf
commit 6ade59cc09
2 changed files with 25 additions and 0 deletions

View File

@ -70,6 +70,20 @@ namespace Oqtane.Repository
item.CurrentValues[nameof(IAuditable.ModifiedBy)] = username;
item.CurrentValues[nameof(IAuditable.ModifiedOn)] = date;
}
if (item.Entity is ISoftDeletable softDeleted)
{
if ((bool)item.CurrentValues[nameof(ISoftDeletable.IsSoftDeleted)])
{
item.CurrentValues[nameof(ISoftDeletable.DeletedBy)] = username;
item.CurrentValues[nameof(ISoftDeletable.DeletedOn)] = date;
}
else
{
item.CurrentValues[nameof(ISoftDeletable.DeletedBy)] = null;
item.CurrentValues[nameof(ISoftDeletable.DeletedOn)] = null;
}
}
}
return base.SaveChanges();

View File

@ -0,0 +1,11 @@
using System;
namespace Oqtane.Models
{
public interface ISoftDeletable
{
string DeletedBy { get; set; }
DateTime? DeletedOn { get; set; }
bool IsSoftDeleted { get; set; }
}
}