using Monitoring.Core.Domain.EventManagement;
using Monitoring.Core.Domain.Primitives;

namespace Monitoring.Core.Domain;

/// <summary>
/// Зона.
/// </summary>
public class Zone
{
	public ZoneId Id { get; } = default!;
	public ZoneIndex Index { get; private set; } = default!;
	public ZoneName Name { get; private set; } = default!;
	public ZoneDescription Description { get; private set; } = default!;
	public Area Area { get; } = default!;
	public AreaId AreaId { get; } = default!;

	public List<Alarm> Alarms { get; } = [];
	public List<Fault> Faults { get; } = [];

	// For EF Core
	protected Zone() { }

	public static Zone Create(ZoneIndex index, ZoneName name, ZoneDescription description, AreaId areaId)
	{
		// TODO: check parameters and exchange return type to "Result<Zone>"
		ZoneId id = new(Guid.NewGuid());
		return new Zone(id, index, name, description, areaId);
	}

	public static Zone Create(ZoneId id, ZoneIndex index, ZoneName name, ZoneDescription description, AreaId areaId)
	{
		// TODO: check parameters and exchange return type to "Result<Zone>"
		return new Zone(id, index, name, description, areaId);
	}

	private Zone(ZoneId id, ZoneIndex index, ZoneName name, ZoneDescription description, AreaId areaId)
	{
		Id = id;
		Index = index;
		Name = name;
		Description = description;
		AreaId = areaId;
	}

	public void Update(ZoneIndex index, ZoneName name, ZoneDescription description)
	{
		Index = index;
		Name = name;
		Description = description;
	}
}