using Monitoring.Core.Domain.MemberPrimitives;
using Monitoring.Core.Domain.OrganizationManagement;
using Monitoring.Core.Domain.UserPrimitives;

namespace Monitoring.Core.Domain;

/// <summary>
/// Член организации.
/// </summary>
public class Member
{
	private Member(MemberId id, OrganizationId organizationId, UserId userId)
	{
		Id = id;
		OrganizationId = organizationId;
		UserId = userId;
	}

	protected Member()
	{
	}

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

	/// <summary>
	/// ИД пользователя.
	/// </summary>
	public UserId UserId { get; } = default!;

	/// <summary>
	/// Пользователь.
	/// </summary>
	public User User { get; } = default!;

	/// <summary>
	/// ИД организации, в которой существует пользователь.
	/// </summary>
	public OrganizationId OrganizationId { get; } = default!;

	/// <summary>
	/// Организация, в которой существует пользователь.
	/// </summary>
	public Organization Organization { get; } = default!;

	/// <summary>
	/// Доступы.
	/// </summary>
	public List<Access> Accesses { get; set; } = [];

	/// <summary>
	/// Создает члена организации.
	/// </summary>
	/// <param name="organizationId">ИД организации.</param>
	/// <param name="userId">ИД пользователя.</param>
	/// <returns>Член организации.</returns>
	public static Member Create(OrganizationId organizationId, UserId userId)
	{
		return new Member(
			new MemberId(Guid.NewGuid()),
			organizationId,
			userId);
	}
}