aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Data/Database/BaseWithOwner.cs
diff options
context:
space:
mode:
Diffstat (limited to 'code/api/src/Data/Database/BaseWithOwner.cs')
-rw-r--r--code/api/src/Data/Database/BaseWithOwner.cs31
1 files changed, 23 insertions, 8 deletions
diff --git a/code/api/src/Data/Database/BaseWithOwner.cs b/code/api/src/Data/Database/BaseWithOwner.cs
index 1eb99f4..84b5bfe 100644
--- a/code/api/src/Data/Database/BaseWithOwner.cs
+++ b/code/api/src/Data/Database/BaseWithOwner.cs
@@ -1,19 +1,34 @@
namespace IOL.GreatOffice.Api.Data.Database;
/// <summary>
-/// Base class for all entities.
+/// Base class for all entities with ownership.
/// </summary>
public class BaseWithOwner : Base
{
protected BaseWithOwner() { }
- protected BaseWithOwner(Guid userId) {
- UserId = userId;
+ protected BaseWithOwner(LoggedInUserModel loggedInUser) {
+ CreatedBy = loggedInUser.Id;
}
- public Guid? UserId { get; set; }
- public Guid? TenantId { get; init; }
- public Guid? ModifiedById { get; init; }
- public Guid? CreatedById { get; init; }
- public Guid? DeletedById { get; init; }
+ public Guid? UserId { get; private set; }
+ public Guid? TenantId { get; private set; }
+ public Guid? ModifiedBy { get; private set; }
+ public Guid? CreatedBy { get; private set; }
+ public Guid? DeletedBy { get; private set; }
+
+ public void SetDeleted(Guid userId) {
+ DeletedBy = userId;
+ SetDeleted();
+ }
+
+ public void SetModified(Guid userId) {
+ ModifiedBy = userId;
+ SetModified();
+ }
+
+ public void SetOwnerIds(Guid userId = default, Guid tenantId = default) {
+ if (tenantId != default) TenantId = tenantId;
+ if (userId != default) UserId = userId;
+ }
} \ No newline at end of file