using System.Linq.Expressions;

using Monitoring.Core.Domain;

namespace Monitoring.Features.Areas;

/// <summary>
/// Модель площади.
/// </summary>
/// <param name="Id">Идентификатор.</param>
/// <param name="Name">Название.</param>
public record AreaModel(
	Guid Id,
	int Index,
	string Name,
	string Description,
	Guid AssetId,
	bool HasAlarms,
	bool HasFaults
)
{
	public static readonly Expression<Func<Area, AreaModel>> Projection = x => new AreaModel(
		x.Id.Value,
		x.Index.Value,
		x.Name.Value,
		x.Description.Value,
		x.Asset.Id.Value,
		x.Zones.Any(x => x.Alarms.Count != 0),
		x.Zones.Any(x => x.Faults.Count != 0));
}