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

namespace Monitoring.Features.CheckListManagement;

public sealed record CheckListTemplateModel(
	Guid Id,
	CheckListType Type,
	List<CheckListTemplateItemModel> Items
)
{
	public static CheckListTemplateModel FromEntity(CheckListTemplate entity)
	{
		return new(
			entity.Id.Value,
			entity.Type,
			entity.Items.Select(CheckListTemplateItemModel.FromEntity).ToList()
		);
	}

	public static Expression<Func<CheckListTemplate, CheckListTemplateModel>> Projection =>
		x =>
			new(
				x.Id.Value,
				x.Type,
				x.Items.AsQueryable().Select(CheckListTemplateItemModel.Projection).ToList()
			);
};
