namespace CashLineERP.Domain.Identity;

public sealed class UserFunctionAssignment
{
    public long Id { get; private set; }

    public long UserId { get; private set; }

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

    public DateTime EffectiveFromUtc { get; private set; }

    public DateTime? EffectiveToUtc { get; private set; }

    public bool IsActive { get; private set; } = true;

    public ApplicationUser? User { get; private set; }

    public UserFunctionAssignment(long userId, string functionCode, DateTime effectiveFromUtc)
    {
        UserId = userId;
        FunctionCode = functionCode;
        EffectiveFromUtc = effectiveFromUtc;
    }

    private UserFunctionAssignment()
    {
    }

    public void Deactivate(DateTime effectiveToUtc)
    {
        EffectiveToUtc = effectiveToUtc;
        IsActive = false;
    }
}
