Skip to content

Commit

Permalink
Merge pull request #11 from PandaTechAM/development
Browse files Browse the repository at this point in the history
New method added for syncing audit base entities
  • Loading branch information
HaikAsatryan authored Feb 28, 2025
2 parents 3e3459c + b84454e commit a746935
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/EFCore.AuditBase/AuditEntityBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ namespace EFCore.AuditBase;

public abstract class AuditEntityBase
{
[Required]
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

public required long? CreatedByUserId { get; init; }
public DateTime? UpdatedAt { get; private set; }
public long? UpdatedByUserId { get; private set; }

[Required]
public bool Deleted { get; private set; }

[Required]
[ConcurrencyCheck]
public int Version { get; private set; } = 1;

Expand All @@ -32,4 +28,11 @@ public void MarkAsDeleted(long? userId, DateTime? updatedAt = null)
UpdatedByUserId = userId;
Version++;
}
public void SyncAuditBase(AuditEntityBase source)
{
UpdatedAt = source.UpdatedAt;
UpdatedByUserId = source.UpdatedByUserId;
Deleted = source.Deleted;
Version = source.Version;
}
}
4 changes: 2 additions & 2 deletions src/EFCore.AuditBase/EFCore.AuditBase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Authors>Pandatech</Authors>
<Copyright>MIT</Copyright>
<Version>3.0.1</Version>
<Version>3.0.2</Version>
<PackageId>Pandatech.EFCore.AuditBase</PackageId>
<Title>Pandatech EFCore AuditBase</Title>
<PackageTags>Pandatech, library, audit, optimistic lock, tracking, efcore, soft delete, versioning</PackageTags>
<Description>Pandatech.EFCore.AuditBase provides a robust auditing solution for EF Core applications, ensuring traceability and integrity of entity modifications. It seamlessly integrates auditing capabilities into your EF Core entities, enforcing best practices for entity state changes, deletion handling, and versioning to support concurrency control. Ideal for applications requiring a reliable audit trail and compliance with data handling standards.</Description>
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-efcore-audit-base</RepositoryUrl>
<PackageReleaseNotes>Nuget updates</PackageReleaseNotes>
<PackageReleaseNotes>New method added for syncing audit base entities</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/EFCore.AuditBase.Demo/EFCore.AuditBase.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit a746935

Please sign in to comment.