aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/Database/Models/_Base.cs
blob: 2a05a3ae4988babdc58acfa2017afb589894d4db (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
namespace I2R.Storage.Api.Database.Models;

public class Base
{
    public Base() {
        Id = Guid.NewGuid();
        CreatedAt = AppDateTime.UtcNow;
    }

    public Base(Guid createdBy) {
        Id = Guid.NewGuid();
        CreatedAt = AppDateTime.UtcNow;
        CreatedBy = createdBy;
    }

    public Guid Id { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime? LastModifiedAt { get; set; }
    public DateTime? LastDeletedAt { get; set; }
    public Guid? OwningUserId { get; set; }
    public Guid? LastModifiedBy { get; set; }
    public Guid? LastDeletedBy { get; set; }
    public Guid? CreatedBy { get; set; }

    public void SetDeleted(Guid performingUserId = default) {
        LastDeletedAt = AppDateTime.UtcNow;
        LastDeletedBy = performingUserId;
    }

    public void SetModified(Guid performingUserId = default) {
        LastModifiedAt = AppDateTime.UtcNow;
        LastModifiedBy = performingUserId;
    }
}