using System.Linq.Expressions;
using Monitoring.Core.Domain.CheckListManagement;

namespace Monitoring.Features.CheckListManagement;

public record CheckListModel(Guid Id, Guid TemplateId, Guid AlarmId, List<CheckListItemModel> Items)
{
	public static readonly Expression<Func<CheckList, CheckListModel>> Projection =
		entity => new CheckListModel(
			entity.Id.Value,
			entity.TemplateId.Value,
			entity.AlarmScopeId.Value,
			entity
				.Items.OrderBy(i => i.Template.Index)
				.Select(i => new CheckListItemModel(i.Id.Value, i.TemplateId.Value, i.IsChecked))
				.ToList()
		);
}

public record CheckListItemModel(Guid Id, Guid TemplateItemId, bool IsChecked);
