using IamService.Domain.SeedWork;

namespace IamService.Domain.AggregatesModel.AuditAggregate;

/// <summary>
/// EN: Audit event type enumeration.
/// VI: Enumeration loại audit event.
/// </summary>
public class AuditEventType : Enumeration
{
    // Authentication events
    public static readonly AuditEventType Login = new(1, nameof(Login));
    public static readonly AuditEventType Logout = new(2, nameof(Logout));
    public static readonly AuditEventType LoginFailed = new(3, nameof(LoginFailed));
    public static readonly AuditEventType PasswordChanged = new(4, nameof(PasswordChanged));
    public static readonly AuditEventType PasswordResetRequested = new(5, nameof(PasswordResetRequested));
    public static readonly AuditEventType TwoFactorEnabled = new(6, nameof(TwoFactorEnabled));
    public static readonly AuditEventType TwoFactorDisabled = new(7, nameof(TwoFactorDisabled));

    // User events
    public static readonly AuditEventType UserCreated = new(10, nameof(UserCreated));
    public static readonly AuditEventType UserUpdated = new(11, nameof(UserUpdated));
    public static readonly AuditEventType UserDeleted = new(12, nameof(UserDeleted));
    public static readonly AuditEventType UserLocked = new(13, nameof(UserLocked));
    public static readonly AuditEventType UserUnlocked = new(14, nameof(UserUnlocked));

    // Access events
    public static readonly AuditEventType AccessRequested = new(20, nameof(AccessRequested));
    public static readonly AuditEventType AccessGranted = new(21, nameof(AccessGranted));
    public static readonly AuditEventType AccessRevoked = new(22, nameof(AccessRevoked));
    public static readonly AuditEventType AccessDenied = new(23, nameof(AccessDenied));
    public static readonly AuditEventType PrivilegedAccessGranted = new(24, nameof(PrivilegedAccessGranted));
    public static readonly AuditEventType PrivilegedAccessRevoked = new(25, nameof(PrivilegedAccessRevoked));

    // Organization events
    public static readonly AuditEventType OrganizationCreated = new(30, nameof(OrganizationCreated));
    public static readonly AuditEventType OrganizationUpdated = new(31, nameof(OrganizationUpdated));
    public static readonly AuditEventType GroupMemberAdded = new(32, nameof(GroupMemberAdded));
    public static readonly AuditEventType GroupMemberRemoved = new(33, nameof(GroupMemberRemoved));

    // Policy events
    public static readonly AuditEventType PolicyCreated = new(40, nameof(PolicyCreated));
    public static readonly AuditEventType PolicyActivated = new(41, nameof(PolicyActivated));
    public static readonly AuditEventType PolicyDeactivated = new(42, nameof(PolicyDeactivated));

    // Compliance events
    public static readonly AuditEventType ComplianceReportGenerated = new(50, nameof(ComplianceReportGenerated));
    public static readonly AuditEventType ViolationDetected = new(51, nameof(ViolationDetected));
    public static readonly AuditEventType ViolationResolved = new(52, nameof(ViolationResolved));

    public AuditEventType(int id, string name) : base(id, name) { }

    public static AuditEventType? FromId(int id) => GetAll<AuditEventType>().FirstOrDefault(e => e.Id == id);
    public static AuditEventType? FromName(string name) => GetAll<AuditEventType>().FirstOrDefault(e => e.Name == name);
}
