Rename Interface in IDeletable and property in IsDeleted
This commit is contained in:
parent
182a156bd8
commit
4792ea697b
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Shared;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -71,19 +72,19 @@ namespace Oqtane.Repository
|
||||||
item.CurrentValues[nameof(IAuditable.ModifiedOn)] = date;
|
item.CurrentValues[nameof(IAuditable.ModifiedOn)] = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Entity is ISoftDeletable softDeleted && item.State != EntityState.Added)
|
if (item.Entity is IDeletable deleted && item.State != EntityState.Added)
|
||||||
{
|
{
|
||||||
if ((bool)item.CurrentValues[nameof(ISoftDeletable.IsSoftDeleted)]
|
if ((bool)item.CurrentValues[nameof(IDeletable.IsDeleted)]
|
||||||
&& !item.GetDatabaseValues().GetValue<bool>(nameof(ISoftDeletable.IsSoftDeleted)))
|
&& !item.GetDatabaseValues().GetValue<bool>(nameof(IDeletable.IsDeleted)))
|
||||||
{
|
{
|
||||||
item.CurrentValues[nameof(ISoftDeletable.DeletedBy)] = username;
|
item.CurrentValues[nameof(IDeletable.DeletedBy)] = username;
|
||||||
item.CurrentValues[nameof(ISoftDeletable.DeletedOn)] = date;
|
item.CurrentValues[nameof(IDeletable.DeletedOn)] = date;
|
||||||
}
|
}
|
||||||
else if (!(bool)item.CurrentValues[nameof(ISoftDeletable.IsSoftDeleted)]
|
else if (!(bool)item.CurrentValues[nameof(IDeletable.IsDeleted)]
|
||||||
&& item.GetDatabaseValues().GetValue<bool>(nameof(ISoftDeletable.IsSoftDeleted)))
|
&& item.GetDatabaseValues().GetValue<bool>(nameof(IDeletable.IsDeleted)))
|
||||||
{
|
{
|
||||||
item.CurrentValues[nameof(ISoftDeletable.DeletedBy)] = null;
|
item.CurrentValues[nameof(IDeletable.DeletedBy)] = null;
|
||||||
item.CurrentValues[nameof(ISoftDeletable.DeletedOn)] = null;
|
item.CurrentValues[nameof(IDeletable.DeletedOn)] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Oqtane.Models
|
namespace Oqtane.Shared
|
||||||
{
|
{
|
||||||
public interface ISoftDeletable
|
public interface IDeletable
|
||||||
{
|
{
|
||||||
string DeletedBy { get; set; }
|
string DeletedBy { get; set; }
|
||||||
DateTime? DeletedOn { get; set; }
|
DateTime? DeletedOn { get; set; }
|
||||||
bool IsSoftDeleted { get; set; }
|
bool IsDeleted { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user