using Monitoring.Core.Domain.UserPrimitives;

namespace Monitoring.Core.Domain.FireDepartmentManagement;

/// <summary>
/// Доступ пользователя на отправку заявок в ДЧС.
/// </summary>
public class FireDepartmentAccess
{
	/// <summary>
	/// Идентификатор.
	/// </summary>
	public FireDepartmentAccessId Id { get; } = null!;

	/// <summary>
	/// Пользователь, которому предоставляется доступ.
	/// </summary>
	public User User { get; } = null!;

	/// <summary>
	/// ИД пользователя, которому предоставляется доступ.
	/// </summary>
	public UserId UserId { get; } = null!;

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

	/// <summary>
	/// ИД пожарной части.
	/// </summary>
	public FireDepartmentId DepartmentId { get; } = null!;

	/// <summary>
	/// Создает экземпляр доступа.
	/// </summary>
	/// <param name="userId">ИД пользователя.</param>
	/// <param name="departmentId">ИД пожарной части.</param>
	/// <returns>Экземпляр доступа.</returns>
	public static FireDepartmentAccess Create(
		UserId userId,
		FireDepartmentId departmentId
	)
	{
		return new(
			new(Guid.CreateVersion7()),
			userId,
			departmentId
		);
	}

	private FireDepartmentAccess(
		FireDepartmentAccessId id,
		UserId userId,
		FireDepartmentId departmentId
	)
	{
		this.Id = id;
		this.UserId = userId;
		this.DepartmentId = departmentId;
	}

	/// <summary>
	/// Constructor for EF.
	/// </summary>
	protected FireDepartmentAccess() { }
}
