using System.Linq.Expressions;
using Monitoring.Core.Domain.EventManagement;
using Monitoring.Features.AlarmManagement;

namespace Monitoring.Models;

public record AlarmModel(
	Guid Id,
	EventModel Event,
	Guid ZoneId,
	[property: Obsolete("Use AlarmScopeStatus instead")] bool IsReal,
	Guid ScopeId
)
{
	public static Expression<Func<Alarm, AlarmModel>> FromEntity =>
		entity => new AlarmModel(
			entity.Id.Value,
			// TODO: Возможно тут стоит изменить на выражение EventModel.FromEntity
			new EventModel(
				entity.Event.Id.Value,
				entity.Event.CreatedAt,
				entity.Event.AssetId.Value,
				entity.Event.Code.Value.Value,
				entity.Event.Code.IsActive,
				entity.Event.AreaIndex.Value,
				entity.Event.ZoneIndex.Value
			),
			entity.ZoneId.Value,
			entity.IsReal,
			entity.ScopeId.Value
		);
}
