Skip to content

Commit

Permalink
feat: full audited entity model (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoBaSs84 authored Dec 25, 2024
2 parents 33ce99d + d198b39 commit a34dc19
Show file tree
Hide file tree
Showing 49 changed files with 713 additions and 190 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions.Components;

/// <summary>
/// The concurrency interface.
/// The interface for concurrency based components.
/// </summary>
public interface IConcurrency
{
/// <summary>
/// The current timestamp or row version.
/// The current timestamp or row version of the data row.
/// </summary>
byte[] Timestamp { get; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions.Components;

/// <summary>
/// The enumerator interface.
/// The interface for enumerator based components.
/// </summary>
public interface IEnumerator
{
Expand All @@ -13,5 +13,5 @@ public interface IEnumerator
/// <summary>
/// The description of the enumerator.
/// </summary>
string Description { get; set; }
string? Description { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions.Components;

/// <summary>
/// The identity interface.
/// The interface for identity based components.
/// </summary>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
public interface IIdentity<TKey> where TKey : IEquatable<TKey>
Expand All @@ -12,7 +12,7 @@ public interface IIdentity<TKey> where TKey : IEquatable<TKey>
TKey Id { get; set; }
}

/// <inheritdoc/>
/// <inheritdoc cref="IIdentity{TKey}"/>
/// <remarks>
/// The primary key is of type <see cref="Guid"/>.
/// </remarks>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions.Components;

/// <summary>
/// The soft deleteable interface.
/// The interface for soft deleteable components.
/// </summary>
public interface ISoftDeletable
{
/// <summary>
/// Is the data row in a soft deleted state?
/// Indicates if the data row in a soft deleted state.
/// </summary>
bool IsDeleted { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions.Components;

/// <summary>
/// The interface for time audited components.
/// </summary>
public interface ITimeAudited
{
/// <summary>
/// The initial creation time of the data row.
/// </summary>
DateTime Created { get; set; }

/// <summary>
/// The last editing time of the data row.
/// </summary>
DateTime? Edited { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions.Components;

/// <summary>
/// The interface for user audited components.
/// </summary>
/// <typeparam name="TCreator">The type of the creator column.</typeparam>
/// <typeparam name="TEditor">The type of the editor column.</typeparam>
public interface IUserAudited<TCreator, TEditor>
{
/// <summary>
/// The initial creator of the data row.
/// </summary>
TCreator Creator { get; set; }

/// <summary>
/// The last editor of the data row.
/// </summary>
TEditor Editor { get; set; }
}

/// <inheritdoc cref="IUserAudited{TCreator, TEditor}"/>
/// <remarks>
/// The user auditing columns are of type <see cref="string"/>.
/// </remarks>
public interface IUserAudited : IUserAudited<string, string?>
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions;

/// <summary>
/// The audited composite model interface.
/// The interface for the audited composite models.
/// </summary>
/// <inheritdoc cref="IConcurrency"/>
/// <inheritdoc cref="IAudited{TCreated, TModified}"/>
public interface IAuditedCompositeModel<TCreated, TModified> : IConcurrency, IAudited<TCreated, TModified>
/// <inheritdoc cref="IUserAudited{TCreator, TEditor}"/>
public interface IAuditedCompositeModel<TCreator, TEditor> : IConcurrency, IUserAudited<TCreator, TEditor>
{ }

/// <inheritdoc/>
/// <inheritdoc cref="IAuditedCompositeModel{TCreator, TEditor}"/>
/// <remarks>
/// The user auditing columns are of type <see cref="string"/>.
/// </remarks>
public interface IAuditedCompositeModel : IAuditedCompositeModel<string, string?>
{ }
27 changes: 19 additions & 8 deletions src/BB84.EntityFrameworkCore.Models.Abstractions/IAuditedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions;

/// <summary>
/// The audited model base interface.
/// The interface for the audited models.
/// </summary>
/// <inheritdoc cref="IIdentity{TKey}"/>
/// <inheritdoc cref="IAudited{TCreated, TModified}"/>
public interface IAuditedModel<TKey, TCreated, TModified> : IIdentityModel<TKey>, IAudited<TCreated, TModified> where TKey : IEquatable<TKey>
/// <inheritdoc cref="IUserAudited{TCreator, TEdited}"/>
public interface IAuditedModel<TKey, TCreator, TEdited> : IIdentityModel<TKey>, IUserAudited<TCreator, TEdited> where TKey : IEquatable<TKey>
{ }

/// <inheritdoc/>
/// <inheritdoc cref="IAuditedModel{TKey, TCreator, TEdited}"/>
/// <remarks>
/// The primary key is of type <see cref="Guid"/>.
/// The user auditing columns are of type <see cref="string"/>.
/// </remarks>
public interface IAuditedModel<TCreated, TModified> : IAuditedModel<Guid, TCreated, TModified>, IIdentityModel
public interface IAuditedModel<TKey> : IAuditedModel<TKey, string, string?>, IUserAudited where TKey : IEquatable<TKey>
{ }

/// <inheritdoc/>
public interface IAuditedModel : IAuditedModel<string, string?>
/// <inheritdoc cref="IAuditedModel{TKey, TCreator, TEdited}"/>
/// <remarks>
/// The identity column is of type <see cref="Guid"/>.
/// </remarks>
public interface IAuditedModel<TCreator, TEdited> : IAuditedModel<Guid, TCreator, TEdited>, IIdentityModel
{ }

/// <inheritdoc cref="IAuditedModel{TKey, TCreator, TEdited}"/>
/// <remarks>
/// The identity column is of type <see cref="Guid"/>.
/// The user auditing columns are of type <see cref="string"/>.
/// </remarks>
public interface IAuditedModel : IAuditedModel<Guid, string, string?>, IIdentityModel, IUserAudited
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions;

/// <summary>
/// The composite model interface.
/// The interface for the composite models.
/// </summary>
public interface ICompositeModel : IConcurrency
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions;

/// <summary>
/// The enumerator model interface.
/// The interface for the enumerator models.
/// </summary>
/// <inheritdoc/>
public interface IEnumeratorModel : IIdentityModel<int>, IEnumerator, ISoftDeletable
/// <inheritdoc cref="IIdentityModel{TKey}"/>
/// <inheritdoc cref="IEnumerator"/>
/// <inheritdoc cref="ISoftDeletable"/>
public interface IEnumeratorModel<TKey> : IIdentityModel<TKey>, IEnumerator, ISoftDeletable where TKey : IEquatable<TKey>
{ }

/// <inheritdoc cref="IEnumeratorModel{TKey}"/>
/// <remarks>
/// The identity column is of type <see cref="int"/>.
/// </remarks>
public interface IEnumeratorModel : IEnumeratorModel<int>
{ }
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using BB84.EntityFrameworkCore.Models.Abstractions.Components;

namespace BB84.EntityFrameworkCore.Models.Abstractions;

/// <summary>
/// The interface for full audited entities.
/// </summary>
/// <inheritdoc cref="IIdentity{TKey}"/>
/// <inheritdoc cref="IUserAudited{TCreator, TEdited}"/>
/// <inheritdoc cref="ITimeAudited"/>
public interface IFullAuditedModel<TKey, TCreator, TEdited> : IIdentityModel<TKey>, IUserAudited<TCreator, TEdited>, ITimeAudited where TKey : IEquatable<TKey>
{ }

/// <inheritdoc cref="IFullAuditedModel{TKey, TCreator, TEdited}"/>
/// <remarks>
/// The user auditing columns are of type <see cref="string"/>.
/// </remarks>
public interface IFullAuditedModel<TKey> : IFullAuditedModel<TKey, string, string?>, IUserAudited where TKey : IEquatable<TKey>
{ }

/// <inheritdoc cref="IFullAuditedModel{TKey, TCreator, TEdited}"/>
/// <remarks>
/// The identity column is of type <see cref="Guid"/>.
/// </remarks>
public interface IFullAuditedModel<TCreator, TEdited> : IFullAuditedModel<Guid, TCreator, TEdited>, IIdentityModel
{ }

/// <inheritdoc cref="IFullAuditedModel{TKey, TCreator, TEdited}"/>
/// <remarks>
/// The identity column is of type <see cref="Guid"/>.
/// The user auditing columns are of type <see cref="string"/>.
/// </remarks>
public interface IFullAuditedModel : IFullAuditedModel<Guid, string, string?>, IIdentityModel, IUserAudited
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace BB84.EntityFrameworkCore.Models.Abstractions;

/// <summary>
/// The model base interface.
/// The interface for the identity models.
/// </summary>
/// <inheritdoc cref="IIdentity{TKey}"/>
/// <inheritdoc cref="IAudited{TCreated, TModified}"/>
/// <inheritdoc cref="IConcurrency"/>
public interface IIdentityModel<TKey> : IIdentity<TKey>, IConcurrency where TKey : IEquatable<TKey>
{ }

/// <inheritdoc/>
/// <inheritdoc cref="IIdentityModel{TKey}"/>
/// <remarks>
/// The primary key is of type <see cref="Guid"/>.
/// The identity column is of type <see cref="Guid"/>.
/// </remarks>
public interface IIdentityModel : IIdentityModel<Guid>
{ }
13 changes: 7 additions & 6 deletions src/BB84.EntityFrameworkCore.Models/AuditedCompositeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
namespace BB84.EntityFrameworkCore.Models;

/// <summary>
/// The audited composite model class.
/// The base implementation for the audited composite models.
/// </summary>
/// <inheritdoc cref="IAuditedCompositeModel{TCreated, TModified}"/>
public abstract class AuditedCompositeModel<TCreated, TModified> : IAuditedCompositeModel<TCreated, TModified>
/// <inheritdoc cref="IAuditedCompositeModel{TCreator, TEdited}"/>
public abstract class AuditedCompositeModel<TCreator, TEdited> : IAuditedCompositeModel<TCreator, TEdited>
{
/// <inheritdoc/>
public byte[] Timestamp { get; } = default!;

/// <inheritdoc/>
public TCreated CreatedBy { get; set; } = default!;
public TCreator Creator { get; set; } = default!;

/// <inheritdoc/>
public TModified ModifiedBy { get; set; } = default!;
public TEdited Editor { get; set; } = default!;
}

/// <inheritdoc/>
/// <inheritdoc cref="AuditedCompositeModel{TCreator, TEdited}"/>
/// <inheritdoc cref="IAuditedCompositeModel"/>
public abstract class AuditedCompositeModel : AuditedCompositeModel<string, string?>, IAuditedCompositeModel
{ }
23 changes: 15 additions & 8 deletions src/BB84.EntityFrameworkCore.Models/AuditedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@
namespace BB84.EntityFrameworkCore.Models;

/// <summary>
/// The audited model class.
/// The base implementation for the audited models.
/// </summary>
/// <inheritdoc cref="IAuditedModel{TKey, TCreated, TModified}"/>
public abstract class AuditedModel<TKey, TCreated, TModified> : IdentityModel<TKey>, IAuditedModel<TKey, TCreated, TModified> where TKey : IEquatable<TKey>
/// <inheritdoc cref="IAuditedModel{TKey, TCreator, TEdited}"/>
public abstract class AuditedModel<TKey, TCreator, TEdited> : IdentityModel<TKey>, IAuditedModel<TKey, TCreator, TEdited> where TKey : IEquatable<TKey>
{
/// <inheritdoc/>
public TCreated CreatedBy { get; set; } = default!;
public TCreator Creator { get; set; } = default!;

/// <inheritdoc/>
public TModified ModifiedBy { get; set; } = default!;
public TEdited Editor { get; set; } = default!;
}

/// <inheritdoc/>
public abstract class AuditedModel<TCreated, TModified> : AuditedModel<Guid, TCreated, TModified>, IAuditedModel<TCreated, TModified>
/// <inheritdoc cref="AuditedModel{TKey, TCreator, TEdited}"/>
/// <inheritdoc cref="IAuditedModel{TKey}"/>
public abstract class AuditedModel<TKey> : AuditedModel<TKey, string, string?>, IAuditedModel<TKey> where TKey : IEquatable<TKey>
{ }

/// <inheritdoc/>
/// <inheritdoc cref="AuditedModel{TKey, TCreator, TEdited}"/>
/// <inheritdoc cref="IAuditedModel{TCreator, TEdited}"/>
public abstract class AuditedModel<TCreator, TEdited> : AuditedModel<Guid, TCreator, TEdited>, IAuditedModel<TCreator, TEdited>
{ }

/// <inheritdoc cref="AuditedModel{TKey, TCreator, TEdited}"/>
/// <inheritdoc cref="IAuditedModel"/>
public abstract class AuditedModel : AuditedModel<Guid, string, string?>, IAuditedModel
{ }
2 changes: 1 addition & 1 deletion src/BB84.EntityFrameworkCore.Models/CompositeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace BB84.EntityFrameworkCore.Models;

/// <summary>
/// The composite model class.
/// The base implementation for the composite models.
/// </summary>
/// <inheritdoc cref=" ICompositeModel"/>
public abstract class CompositeModel : ICompositeModel
Expand Down
Loading

0 comments on commit a34dc19

Please sign in to comment.