using IamService.Domain.SeedWork;

namespace IamService.Domain.AggregatesModel.ComplianceAggregate;

/// <summary>
/// EN: Compliance violation entity.
/// VI: Entity vi phạm tuân thủ.
/// </summary>
public class ComplianceViolation : Entity
{
    private Guid _reportId;
    private string _rule = null!;
    private ViolationSeverity _severity = null!;
    private string _description = null!;
    private string? _remediation;
    private string? _affectedResource;
    private bool _resolved;
    private DateTime? _resolvedAt;

    public Guid ReportId => _reportId;
    public string Rule => _rule;
    public ViolationSeverity Severity => _severity;
    public string Description => _description;
    public string? Remediation => _remediation;
    public string? AffectedResource => _affectedResource;
    public bool Resolved => _resolved;
    public DateTime? ResolvedAt => _resolvedAt;

    protected ComplianceViolation() { _severity = ViolationSeverity.Medium; }

    public ComplianceViolation(Guid reportId, string rule, ViolationSeverity severity, string description, string? remediation = null, string? affectedResource = null)
    {
        Id = Guid.NewGuid();
        _reportId = reportId;
        _rule = rule;
        _severity = severity;
        _description = description;
        _remediation = remediation;
        _affectedResource = affectedResource;
        _resolved = false;
    }

    public void Resolve()
    {
        _resolved = true;
        _resolvedAt = DateTime.UtcNow;
    }
}
