using System.Linq.Expressions;

using Monitoring.Core.Domain.EventManagement;

namespace Monitoring.Models;

public record FaultModel(
	Guid Id,
	EventModel Event,
	Guid ZoneId
)
{
	public static Expression<Func<Fault, FaultModel>> FromEntity => entity => new FaultModel(
		entity.Id.Value,
		new EventModel(
			entity.Event.Id.Value,
			entity.Event.CreatedAt,
			entity.Event.Asset.Id.Value,
			entity.Event.Code.Value.Value,
			entity.Event.Code.IsActive,
			entity.Event.AreaIndex.Value,
			entity.Event.ZoneIndex.Value
		),
		entity.ZoneId.Value);
}