Files
monorepo/LCU.API.Internal.Dispatcher/LCU.Api.Internal.Dispatcher/Services/NotificationService.cs
T
2026-03-24 15:26:03 -05:00

40 lines
1.2 KiB
C#

using System.Collections.Generic;
using Newtonsoft.Json;
using LCU.Library.Internal.NotificationsModels.Models;
using LCU.Api.Internal.DispatcherSharedLib.Configurations;
using LCU.Api.Internal.DispatcherSharedLib.Utilities;
using LCU.Api.Internal.Dispatcher.DataAccess;
namespace LCU.Api.Internal.Dispatcher.Services;
public class NotificationService : INotificationService
{
private readonly INotificationsApiDao _notificationsApiDao;
public NotificationService(INotificationsApiDao notificationsApiDao)
{
_notificationsApiDao = notificationsApiDao;
}
public async Task<bool> SendEmailAsync(string recipient, string subject, string emailTemplate)
{
try
{
var emailRequest = new EmailRequest
{
Recipient = new List<string>() { recipient },
Subject = subject,
Body = emailTemplate
};
await _notificationsApiDao.SendEmailAsync(emailRequest);
return true;
}
catch (Exception exception)
{
Log.Error(exception, $"Failure to send email from Dispatcher");
return false;
}
}
}