Files
Swarm/DysonNetwork.Common/Models/ModelBase.cs

33 lines
1.1 KiB
C#

using System.ComponentModel.DataAnnotations;
using NodaTime;
namespace DysonNetwork.Common.Models;
/// <summary>
/// Base class for all entity models in the system.
/// Provides common properties and functionality for tracking entity lifecycle.
/// </summary>
public abstract class ModelBase
{
/// <summary>
/// Gets or sets the unique identifier for the entity.
/// </summary>
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary>
/// Gets or sets the date and time when the entity was created, in UTC.
/// </summary>
public Instant CreatedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
/// <summary>
/// Gets or sets the date and time when the entity was last updated, in UTC.
/// </summary>
public Instant UpdatedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
/// <summary>
/// Gets or sets the date and time when the entity was soft-deleted, in UTC.
/// Null if the entity has not been deleted.
/// </summary>
public Instant? DeletedAt { get; set; }
}