using Monitoring.Core.Domain.AssetManagement;
using Monitoring.Core.Domain.Primitives;

namespace Monitoring.Core.Domain;

/// <summary>
/// Площадь.
/// </summary>
public class Area
{
	/// <summary>
	/// Идентификатор.
	/// </summary>
	public AreaId Id { get; } = default!;

	/// <summary>
	/// Индекс.
	/// </summary>
	public AreaIndex Index { get; private set; } = default!;

	/// <summary>
	/// Наименование.
	/// </summary>
	public AreaName Name { get; private set; } = default!;

	/// <summary>
	/// Описание.
	/// </summary>
	public AreaDescription Description { get; private set; } = default!;

	/// <summary>
	/// Объект.
	/// </summary>
	public Asset Asset { get; } = default!;

	/// <summary>
	/// ИД объекта.
	/// </summary>
	public AssetId AssetId { get; } = default!;

	/// <summary>
	/// Зоны.
	/// </summary>
	public List<Zone> Zones { get; } = [];

	/// <summary>
	/// Взят ли за охрану.
	/// </summary>
	public bool IsGuarded { get; set; }

	/// <summary>
	/// Создает площадь.
	/// </summary>
	/// <param name="index">Индекс.</param>
	/// <param name="name">Наименование.</param>
	/// <param name="description">Описание.</param>
	/// <param name="assetId">ИД объекта.</param>
	/// <returns>Площадь.</returns>
	public static Area Create(
		AreaIndex index,
		AreaName name,
		AreaDescription description,
		AssetId assetId)
	{
		return new Area(
			new AreaId(Guid.NewGuid()),
			index,
			name,
			description,
			assetId
		);
	}

	public static Area Create(
		AreaId id,
		AreaIndex index,
		AreaName name,
		AreaDescription description,
		AssetId assetId)
	{
		return new Area(
			id,
			index,
			name,
			description,
			assetId
		);
	}

	private Area(AreaId id, AreaIndex index, AreaName name, AreaDescription description, AssetId assetId)
	{
		Id = id;
		Index = index;
		Name = name;
		Description = description;
		AssetId = assetId;
	}

	// For EF Core
	protected Area() { }

	public void Update(AreaIndex index, AreaName name, AreaDescription description)
	{
		Index = index;
		Name = name;
		Description = description;
	}
}
