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

namespace MembershipService.Domain.Events;

/// <summary>
/// EN: Domain event raised when a member levels up.
/// VI: Domain event được phát ra khi member lên level.
/// </summary>
/// <remarks>
/// EN: This event is used to trigger side effects like rewards, notifications, etc.
/// VI: Event này được dùng để trigger các side effects như rewards, notifications, etc.
/// </remarks>
public class MemberLevelUpDomainEvent : 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 leveled up.
    /// VI: Member đã lên level.
    /// </summary>
    public Member Member { get; }

    /// <summary>
    /// EN: Previous level before leveling up.
    /// VI: Level trước khi lên.
    /// </summary>
    public int OldLevel { get; }

    /// <summary>
    /// EN: New level after leveling up.
    /// VI: Level mới sau khi lên.
    /// </summary>
    public int NewLevel { get; }

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

    public MemberLevelUpDomainEvent(Member member, int oldLevel, int newLevel)
    {
        Member = member ?? throw new ArgumentNullException(nameof(member));
        OldLevel = oldLevel;
        NewLevel = newLevel;
    }
}
