using CashLineERP.Domain.Common;

namespace CashLineERP.Domain.Audit;

public sealed class AuditEvent : Entity
{
    public long Id { get; private set; }

    public string ModuleCode { get; private set; } = string.Empty;

    public string EntityName { get; private set; } = string.Empty;

    public long EntityId { get; private set; }

    public string ActionCode { get; private set; } = string.Empty;

    public long? ActorUserId { get; private set; }

    public long? BranchId { get; private set; }

    public string? OldValue { get; private set; }

    public string? NewValue { get; private set; }

    public DateTime OccurredAtUtc { get; private set; } = DateTime.UtcNow;

    public AuditEvent(
        string moduleCode,
        string entityName,
        long entityId,
        string actionCode,
        long? actorUserId,
        long? branchId = null,
        string? oldValue = null,
        string? newValue = null)
    {
        ModuleCode = moduleCode;
        EntityName = entityName;
        EntityId = entityId;
        ActionCode = actionCode;
        ActorUserId = actorUserId;
        BranchId = branchId;
        OldValue = oldValue;
        NewValue = newValue;
    }

    private AuditEvent()
    {
    }
}
