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(); } } }