:drunk: No idea what did AI did
This commit is contained in:
40
DysonNetwork.Pass/Models/ModelBase.cs
Normal file
40
DysonNetwork.Pass/Models/ModelBase.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Pass.Models;
|
||||
|
||||
public abstract class ModelBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public Instant CreatedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
|
||||
public Instant? UpdatedAt { get; set; }
|
||||
public Instant? DeletedAt { get; set; }
|
||||
|
||||
public bool IsDeleted => DeletedAt != null;
|
||||
|
||||
public void MarkAsUpdated()
|
||||
{
|
||||
UpdatedAt = SystemClock.Instance.GetCurrentInstant();
|
||||
}
|
||||
|
||||
public void MarkAsDeleted()
|
||||
{
|
||||
if (DeletedAt == null)
|
||||
{
|
||||
DeletedAt = SystemClock.Instance.GetCurrentInstant();
|
||||
MarkAsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public void Restore()
|
||||
{
|
||||
if (DeletedAt != null)
|
||||
{
|
||||
DeletedAt = null;
|
||||
MarkAsUpdated();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user