namespace CashLineERP.Domain.Identity;

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

    public long UserId { get; private set; }

    public long RoleId { get; private set; }

    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 Role? Role { get; private set; }

    public UserRole(long userId, long roleId, DateTime effectiveFromUtc)
    {
        UserId = userId;
        RoleId = roleId;
        EffectiveFromUtc = effectiveFromUtc;
    }

    private UserRole()
    {
    }

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