using Microsoft.Extensions.Logging;
using CMSMicroservice.Domain.Events;

namespace CMSMicroservice.Application.TransactionsCQ.EventHandlers.RefundTransactionEventHandlers;

public class RefundTransactionEventHandler : INotificationHandler<RefundTransactionEvent>
{
    private readonly ILogger<RefundTransactionEventHandler> _logger;

    public RefundTransactionEventHandler(ILogger<RefundTransactionEventHandler> logger)
    {
        _logger = logger;
    }

    public Task Handle(RefundTransactionEvent notification, CancellationToken cancellationToken)
    {
        _logger.LogInformation("Transaction {OriginalId} refunded with new transaction {RefundId}. Amount: {Amount}", 
            notification.OriginalTransaction.Id,
            notification.RefundTransaction.Id,
            notification.RefundTransaction.Amount);
        
        // اینجا می‌تونیم اعلان به کاربر بفرستیم یا کارهای دیگه انجام بدیم
        
        return Task.CompletedTask;
    }
}
