/Notification.cs Secret
Created
March 11, 2025 16:24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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