using Monitoring.Core.Domain.EventManagement;
using Monitoring.Core.Domain.UserPrimitives;

namespace Monitoring.Core.Domain.FireDepartmentManagement;

/// <summary>
/// Отправка заявки в пожарную часть по тревоге.
/// </summary>
public class AlarmFireDepartmentDispatch
{
	public AlarmFireDepartmentDispatchId Id { get; } = null!;

	public Alarm Alarm { get; } = null!;
	public AlarmId AlarmId { get; } = null!;

	/// <summary>
	/// Отправитель (оператор).
	/// </summary>
	public User Sender { get; } = null!;
	public UserId SenderId { get; } = null!;

	/// <summary>
	/// Время отправки.
	/// </summary>
	public DateTime SentAt { get; } = DateTime.UtcNow;

	/// <summary>
	/// Пожарная часть.
	/// </summary>
	public FireDepartment Department { get; } = null!;
	public FireDepartmentId DepartmentId { get; } = null!;

	/// <summary>
	/// ФИО диспетчера ДЧС.
	/// </summary>
	public Name DispatcherName { get; } = null!;

	/// <summary>
	/// Комментарий к отправке.
	/// </summary>
	public Description Comment { get; } = null!;

	public static AlarmFireDepartmentDispatch Create(
		AlarmId alarmId,
		UserId senderId,
		FireDepartmentId departmentId,
		Name dispatcherName,
		Description comment
	)
	{
		return new(
			new AlarmFireDepartmentDispatchId(Guid.CreateVersion7()),
			alarmId,
			senderId,
			departmentId,
			dispatcherName,
			comment
		);
	}

	private AlarmFireDepartmentDispatch(
		AlarmFireDepartmentDispatchId id,
		AlarmId alarmId,
		UserId senderId,
		FireDepartmentId departmentId,
		Name dispatcherName,
		Description comment
	)
	{
		Id = id;
		AlarmId = alarmId;
		SenderId = senderId;
		DepartmentId = departmentId;
		DispatcherName = dispatcherName;
		Comment = comment;
	}

	protected AlarmFireDepartmentDispatch() { }
}
