Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created March 11, 2025 16:24
public enum NotificationType
{
Email,
Sms
}
public interface INotificationService
{
Task Send(IEnumerable<(NotificationType DeliveryType, string Address)> recipients, string subject, string body);
}
public class NotificationService : INotificationService
{
private readonly ISmsService _smsService;
private readonly SmsOptions _smsOptions;
public NotificationService(ISmsService smsService, IOptions<SmsOptions> smsOptions)
{
_smsService = smsService;
_smsOptions = smsOptions.Value;
}
public async Task Send(IEnumerable<(NotificationType DeliveryType, string Address)> recipients, string subject, string body)
{
foreach (var recipient in recipients)
{
switch (recipient.DeliveryType)
{
case NotificationType.Email:
throw new NotImplementedException();
break;
case NotificationType.Sms:
await _smsService.Send(_smsOptions.From, recipient.Address, subject);
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment