[CHANGE] Reworked db with interceptors
This commit is contained in:
9
Manager.Data/Entities/Audit/AuditableAttribute.cs
Normal file
9
Manager.Data/Entities/Audit/AuditableAttribute.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Manager.Data.Entities.Audit;
|
||||
|
||||
/// <summary>
|
||||
/// Make all properties in the entity audible, if they are changed this will be stored as a history in the db.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class AuditableAttribute : Attribute
|
||||
{
|
||||
}
|
22
Manager.Data/Entities/Audit/EntityHistory.cs
Normal file
22
Manager.Data/Entities/Audit/EntityHistory.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Manager.Data.Entities.Audit;
|
||||
|
||||
public class EntityHistory
|
||||
{
|
||||
[MaxLength(200)]
|
||||
public required string EntityName { get; set; }
|
||||
[MaxLength(200)]
|
||||
public required string EntityId { get; set; }
|
||||
[MaxLength(200)]
|
||||
public required string PropertyName { get; set; }
|
||||
[MaxLength(1000)]
|
||||
public string? OldValue { get; set; }
|
||||
[MaxLength(1000)]
|
||||
public string? NewValue { get; set; }
|
||||
public DateTime ModifiedUtc { get; set; } = DateTime.UtcNow;
|
||||
[MaxLength(200)]
|
||||
public string? ChangedBy { get; set; }
|
||||
public EntityState ChangeType { get; set; }
|
||||
}
|
9
Manager.Data/Entities/Audit/NoAuditAttribute.cs
Normal file
9
Manager.Data/Entities/Audit/NoAuditAttribute.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Manager.Data.Entities.Audit;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies to ignore the properties in the entity to not audit.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class NoAuditAttribute : Attribute
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user