-
-
Save dcomartin/7cdecb6067ae8ca85fc6455d7621772b to your computer and use it in GitHub Desktop.
This file contains hidden or 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