using Monitoring.Core.Domain.AccessPrimitives;
using Monitoring.Core.Domain.AssetGroupManagement;
using Monitoring.Core.Domain.MemberPrimitives;

namespace Monitoring.Core.Domain;

/// <summary>
/// Доступ к объекту.
/// </summary>
public class Access
{
	private Access(AccessId id, AssetGroupId assetGroupId, MemberId memberId)
	{
		Id = id;
		AssetGroupId = assetGroupId;
		MemberId = memberId;
	}

	// For EF Core
	protected Access()
	{
	}

	/// <summary>
	/// ИД.
	/// </summary>
	public AccessId Id { get; } = default!;

	/// <summary>
	/// ИД участника.
	/// </summary>
	public MemberId MemberId { get; } = default!;

	/// <summary>
	/// Участник.
	/// </summary>
	public Member Member { get; } = default!;

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

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

	/// <summary>
	/// Создает доступ участника организации к группе объекта.
	/// </summary>
	/// <param name="assetGroupId">ИД группы объекта.</param>
	/// <param name="memberId">ИД участника.</param>
	/// <returns>Доступ.</returns>
	public static Access Create(
		AssetGroupId assetGroupId,
		MemberId memberId)
	{
		return new Access(new(Guid.NewGuid()), assetGroupId, memberId);
	}

	public static Access Create(
		AccessId id,
		AssetGroupId assetGroupId,
		MemberId memberId)
	{
		return new Access(id, assetGroupId, memberId);
	}
}