aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/Database/Models/_Base.cs
blob: 4fdc6c1d634eacd61880ea0d66aa50df3e931d79 (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
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;
    }

    public void SetOwner(Guid ownerId = default) {
        OwningUserId = ownerId;
    }
}