using System.Linq.Expressions;

using Monitoring.Core.Domain.AssetManagement;

namespace Monitoring.Features.Reports.Contracts;

public record AssetModel(
	Guid Id,
	string Name,
	IEnumerable<string> GroupName,
	bool IsInAlarm
)
{
	public static readonly Expression<Func<Asset, AssetModel>> ToModel = asset => new(
		asset.Id.Value,
		asset.Name.Value,
		asset.Groups.Select(x => x.Name).OrderBy(x => x).Select(x => x.Value),
		asset.Areas.Any(x => x.Zones.Any(x => x.Alarms.Count != 0))
	);
};