using MediatR;
using MembershipService.Domain.AggregatesModel.ExperienceAggregate;
using MembershipService.Domain.AggregatesModel.MemberAggregate;

namespace MembershipService.Domain.Events;

/// <summary>
/// EN: Domain event raised when a member receives experience points.
/// VI: Domain event được phát ra khi member nhận điểm kinh nghiệm.
/// </summary>
/// <remarks>
/// EN: This event is used for logging, analytics, and potential side effects.
/// VI: Event này được dùng cho logging, analytics, và các side effects tiềm năng.
/// </remarks>
public class MemberExperienceAddedDomainEvent : INotification
{
    /// <summary>
    /// EN: Event ID.
    /// VI: ID của event.
    /// </summary>
    public Guid Id { get; } = Guid.NewGuid();

    /// <summary>
    /// EN: When the event occurred.
    /// VI: Thời điểm event xảy ra.
    /// </summary>
    public DateTime OccurredOn { get; } = DateTime.UtcNow;

    /// <summary>
    /// EN: The member who received EXP.
    /// VI: Member đã nhận EXP.
    /// </summary>
    public Member Member { get; }

    /// <summary>
    /// EN: Amount of EXP points received.
    /// VI: Số điểm EXP nhận được.
    /// </summary>
    public int Points { get; }

    /// <summary>
    /// EN: Source of the experience points.
    /// VI: Nguồn gốc của điểm kinh nghiệm.
    /// </summary>
    public ExperienceSource Source { get; }

    /// <summary>
    /// EN: Member ID.
    /// VI: ID của member.
    /// </summary>
    public Guid MemberId => Member.Id;

    public MemberExperienceAddedDomainEvent(
        Member member, 
        int points,
        ExperienceSource source)
    {
        Member = member ?? throw new ArgumentNullException(nameof(member));
        Points = points;
        Source = source ?? throw new ArgumentNullException(nameof(source));
    }
}
