diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-30 16:40:03 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-30 16:40:03 +0100 |
| commit | 0725e4f7cf4c6f723264b6d461b91c660d144cb7 (patch) | |
| tree | aae5876b5760c80679161d918c34d753ec0e2582 /code/api/src/Data/Database/BaseWithOwner.cs | |
| parent | d76c180c9631df015d37138045c79a46cca350e8 (diff) | |
| download | greatoffice-0725e4f7cf4c6f723264b6d461b91c660d144cb7.tar.xz greatoffice-0725e4f7cf4c6f723264b6d461b91c660d144cb7.zip | |
feat: Apiwork
Diffstat (limited to 'code/api/src/Data/Database/BaseWithOwner.cs')
| -rw-r--r-- | code/api/src/Data/Database/BaseWithOwner.cs | 31 |
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 |
