using MiningService.Domain.SeedWork;

namespace MiningService.Domain.AggregatesModel.CircleAggregate;

/// <summary>
/// EN: Circle member entity.
/// VI: Entity thành viên vòng tròn.
/// </summary>
public class CircleMember : Entity
{
    /// <summary>EN: Circle ID / VI: ID vòng tròn</summary>
    public Guid CircleId { get; private set; }

    /// <summary>EN: Miner ID who is member / VI: ID thợ đào là thành viên</summary>
    public Guid MinerId { get; private set; }

    /// <summary>EN: When member joined / VI: Khi thành viên tham gia</summary>
    public DateTime JoinedAt { get; private set; }

    /// <summary>EN: Whether member is active / VI: Thành viên có hoạt động không</summary>
    public bool IsActive { get; private set; }

    // EF Core
    protected CircleMember() { }

    public static CircleMember Create(Guid circleId, Guid minerId)
    {
        return new CircleMember
        {
            Id = Guid.NewGuid(),
            CircleId = circleId,
            MinerId = minerId,
            JoinedAt = DateTime.UtcNow,
            IsActive = true
        };
    }

    public void Deactivate() => IsActive = false;
    public void Activate() => IsActive = true;
}
