namespace CashLineERP.Domain.Identity;

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

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

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

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

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

    public int DisplayOrder { get; private set; }

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

    public DateTime UpdatedAtUtc { get; private set; }

    public long? UpdatedByUserId { get; private set; }

    public PortalMenuSectionDefinition(
        long id,
        string portalCode,
        string userTypeCode,
        string sectionCode,
        string sectionLabel,
        int displayOrder,
        DateTime updatedAtUtc,
        long? updatedByUserId = null)
    {
        Id = id;
        PortalCode = portalCode;
        UserTypeCode = userTypeCode;
        SectionCode = sectionCode;
        SectionLabel = sectionLabel;
        DisplayOrder = displayOrder;
        UpdatedAtUtc = updatedAtUtc;
        UpdatedByUserId = updatedByUserId;
    }

    private PortalMenuSectionDefinition()
    {
    }

    public void Update(string sectionLabel, int displayOrder, bool isEnabled, long actorUserId)
    {
        SectionLabel = sectionLabel.Trim();
        DisplayOrder = displayOrder;
        IsEnabled = isEnabled;
        UpdatedAtUtc = DateTime.UtcNow;
        UpdatedByUserId = actorUserId;
    }
}
