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

namespace CMSMicroservice.Application.DayaLoanCQ.EventHandlers.DayaLoanApprovedEventHandlers;

public class DayaLoanApprovedEventHandler : INotificationHandler<DayaLoanApprovedEvent>
{
    private readonly ILogger<DayaLoanApprovedEventHandler> _logger;

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

    public Task Handle(DayaLoanApprovedEvent notification, CancellationToken cancellationToken)
    {
        _logger.LogInformation("Daya loan approved for user {UserId}. Contract: {ContractNumber}, Transaction: {TransactionId}", 
            notification.User.Id,
            notification.ContractNumber,
            notification.Transaction.Id);
        
        // اینجا می‌تونیم اعلان به کاربر بفرستیم (Email/SMS)
        
        return Task.CompletedTask;
    }
}
