Add basic support for SoftDeletable
This commit is contained in:
parent
4ccca043cf
commit
6ade59cc09
|
@ -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();
|
||||
|
|
11
Oqtane.Shared/Models/ISoftDeletable.cs
Normal file
11
Oqtane.Shared/Models/ISoftDeletable.cs
Normal 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; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user