blob: ebb331ac9888b94731299bcbf883e20918766de3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
namespace IOL.GreatOffice.Api.Data.Database;
/// <summary>
/// Base class for all entities with ownership.
/// </summary>
public abstract class BaseWithOwner : Base
{
protected BaseWithOwner() { }
protected BaseWithOwner(Guid createdBy) {
CreatedBy = createdBy;
}
protected BaseWithOwner(LoggedInUserModel loggedInUser) {
CreatedBy = loggedInUser.Id;
}
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 User OwningUser { get; set; }
public Tenant OwningTenant { get; set; }
public void SetDeleted(Guid userId) {
DeletedBy = userId;
base.SetDeleted();
}
public void SetModified(Guid userId) {
ModifiedBy = userId;
base.SetModified();
}
public void SetOwnerIds(Guid userId = default, Guid tenantId = default) {
if (tenantId != default) TenantId = tenantId;
if (userId != default) UserId = userId;
}
}
|