using adas_core.Domain.Enums;

namespace adas_core.Domain.Models.MongoModels;

public class AlarmItem
{
    public bool Enabled { get; set; }
    public int StartBefore { get; set; } // seconds 
    public int EndAfter { get; set; } // seconds overrides       

    public string? Color
    {
        get => BeaconColor.ToString();
        set
        {
            if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, out AlarmEnum.BeaconColor color))
                BeaconColor = color;
        }
    }

    public AlarmEnum.Severity Severity { get; set; } = AlarmEnum.Severity.None;
    public AlarmEnum.BeaconColor BeaconColor { get; set; } = AlarmEnum.BeaconColor.None;

    public override string ToString()
    {
        List<string> items =
        [
            $"Enabled: {Enabled}",
            $"StartBefore: {StartBefore}",
            $"EndAfter: {EndAfter}",
            $"Severity: {Severity}",
            $"BeaconColorEnum: {BeaconColor}"
        ];
        if (!string.IsNullOrEmpty(Color)) items.Add($"Color: {Color}");


        return "AlarmItem[" + string.Join(", ", items) + "]";
    }
}