Browse Source

Remove the setter from the auditing interfaces.

Resolve #12229
pull/13399/head
maliming 4 years ago
parent
commit
e0b7e7bd10
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 4
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs
  2. 2
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IHasDeletionTime.cs
  3. 2
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IHasModificationTime.cs
  4. 4
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs
  5. 16
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditPropertySetter.cs
  6. 4
      framework/src/Volo.Abp.Core/Volo/Abp/ISoftDelete.cs
  7. 2
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
  8. 2
      framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs
  9. 5
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

4
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs

@ -10,7 +10,7 @@ public interface IDeletionAuditedObject : IHasDeletionTime
/// <summary>
/// Id of the deleter user.
/// </summary>
Guid? DeleterId { get; set; }
Guid? DeleterId { get; }
}
/// <summary>
@ -22,5 +22,5 @@ public interface IDeletionAuditedObject<TUser> : IDeletionAuditedObject
/// <summary>
/// Reference to the deleter user.
/// </summary>
TUser Deleter { get; set; }
TUser Deleter { get; }
}

2
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IHasDeletionTime.cs

@ -11,5 +11,5 @@ public interface IHasDeletionTime : ISoftDelete
/// <summary>
/// Deletion time.
/// </summary>
DateTime? DeletionTime { get; set; }
DateTime? DeletionTime { get; }
}

2
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IHasModificationTime.cs

@ -10,5 +10,5 @@ public interface IHasModificationTime
/// <summary>
/// The last modified time for this entity.
/// </summary>
DateTime? LastModificationTime { get; set; }
DateTime? LastModificationTime { get; }
}

4
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs

@ -10,7 +10,7 @@ public interface IModificationAuditedObject : IHasModificationTime
/// <summary>
/// Last modifier user for this entity.
/// </summary>
Guid? LastModifierId { get; set; }
Guid? LastModifierId { get; }
}
/// <summary>
@ -22,5 +22,5 @@ public interface IModificationAuditedObject<TUser> : IModificationAuditedObject
/// <summary>
/// Reference to the last modifier user of this entity.
/// </summary>
TUser LastModifier { get; set; }
TUser LastModifier { get; }
}

16
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditPropertySetter.cs

@ -99,7 +99,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (targetObject is IHasModificationTime objectWithModificationTime)
{
objectWithModificationTime.LastModificationTime = Clock.Now;
ObjectHelper.TrySetProperty(objectWithModificationTime, x => x.LastModificationTime, () => Clock.Now);
}
}
@ -112,7 +112,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
if (!CurrentUser.Id.HasValue)
{
modificationAuditedObject.LastModifierId = null;
ObjectHelper.TrySetProperty(modificationAuditedObject, x => x.LastModifierId, () => null);
return;
}
@ -120,7 +120,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (multiTenantEntity.TenantId != CurrentUser.TenantId)
{
modificationAuditedObject.LastModifierId = null;
ObjectHelper.TrySetProperty(modificationAuditedObject, x => x.LastModifierId, () => null);
return;
}
}
@ -134,7 +134,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
}
*/
modificationAuditedObject.LastModifierId = CurrentUser.Id;
ObjectHelper.TrySetProperty(modificationAuditedObject, x => x.LastModifierId, () => CurrentUser.Id);
}
protected virtual void SetDeletionTime(object targetObject)
@ -143,7 +143,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (objectWithDeletionTime.DeletionTime == null)
{
objectWithDeletionTime.DeletionTime = Clock.Now;
ObjectHelper.TrySetProperty(objectWithDeletionTime, x => x.DeletionTime, () => Clock.Now);
}
}
}
@ -162,7 +162,7 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
if (!CurrentUser.Id.HasValue)
{
deletionAuditedObject.DeleterId = null;
ObjectHelper.TrySetProperty(deletionAuditedObject, x => x.DeleterId, () => null);
return;
}
@ -170,11 +170,11 @@ public class AuditPropertySetter : IAuditPropertySetter, ITransientDependency
{
if (multiTenantEntity.TenantId != CurrentUser.TenantId)
{
deletionAuditedObject.DeleterId = null;
ObjectHelper.TrySetProperty(deletionAuditedObject, x => x.DeleterId, () => null);
return;
}
}
deletionAuditedObject.DeleterId = CurrentUser.Id;
ObjectHelper.TrySetProperty(deletionAuditedObject, x => x.DeleterId, () => CurrentUser.Id);
}
}

4
framework/src/Volo.Abp.Core/Volo/Abp/ISoftDelete.cs

@ -9,7 +9,7 @@
public interface ISoftDelete
{
/// <summary>
/// Used to mark an Entity as 'Deleted'.
/// Used to mark an Entity as 'Deleted'.
/// </summary>
bool IsDeleted { get; set; }
bool IsDeleted { get; }
}

2
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs

@ -485,7 +485,7 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext,
}
entry.Reload();
entry.Entity.As<ISoftDelete>().IsDeleted = true;
ObjectHelper.TrySetProperty(entry.Entity.As<ISoftDelete>(), x => x.IsDeleted, () => true);
SetDeletionAuditProperties(entry);
}

2
framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs

@ -253,7 +253,7 @@ public class MemoryDbRepository<TMemoryDbContext, TEntity> : RepositoryBase<TEnt
if (entity is ISoftDelete softDeleteEntity && !IsHardDeleted(entity))
{
softDeleteEntity.IsDeleted = true;
ObjectHelper.TrySetProperty(softDeleteEntity, x => x.IsDeleted, () => true);
(await GetCollectionAsync()).Update(entity);
}
else

5
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

@ -294,7 +294,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && !IsHardDeleted(entity))
{
((ISoftDelete)entity).IsDeleted = true;
ObjectHelper.TrySetProperty(((ISoftDelete)entity), x => x.IsDeleted, () => true);
ApplyAbpConceptsForDeletedEntity(entity);
ReplaceOneResult result;
@ -365,8 +365,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
{
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && !IsHardDeleted(entity))
{
((ISoftDelete)entity).IsDeleted = true;
ObjectHelper.TrySetProperty(((ISoftDelete)entity), x => x.IsDeleted, () => true);
softDeletedEntities.Add(entity, SetNewConcurrencyStamp(entity));
}
else

Loading…
Cancel
Save