public virtual async Task ExecuteAsync(SmsNotificationSendingJobArgs args) { var notification = await _notificationRepository.GetAsync(args.NotificationId); var userPhoneNumber = await _userPhoneNumberProvider.GetAsync(notification.UserId); if (userPhoneNumber.IsNullOrWhiteSpace()) { await SaveNotificationResultAsync(notification, false, NotificationConsts.FailureReasons.ReceiverInfoNotFound); return; } var notificationInfo = await _notificationInfoRepository.GetAsync(notification.NotificationInfoId); var properties = _jsonSerializer.Deserialize <IDictionary <string, object> >(notificationInfo .GetDataValue(NotificationProviderSmsConsts.NotificationInfoPropertiesPropertyName).ToString()); var smsMessage = new SmsMessage(userPhoneNumber, notificationInfo.GetDataValue(NotificationProviderSmsConsts.NotificationInfoTextPropertyName) .ToString()); foreach (var property in properties) { smsMessage.Properties.AddIfNotContains(property); } await _smsSender.SendAsync(smsMessage); await SaveNotificationResultAsync(notification, true); }
public virtual async Task ExecuteAsync(EmailNotificationSendingJobArgs args) { var notification = await _notificationRepository.GetAsync(args.NotificationId); var userEmailAddress = await _userEmailAddressProvider.GetAsync(notification.UserId); if (userEmailAddress.IsNullOrWhiteSpace()) { await SaveNotificationResultAsync(notification, false, NotificationConsts.FailureReasons.ReceiverInfoNotFound); return; } var notificationInfo = await _notificationInfoRepository.GetAsync(notification.NotificationInfoId); await _emailSender.SendAsync(userEmailAddress, notificationInfo.GetDataValue(NotificationProviderMailingConsts.NotificationInfoSubjectPropertyName).ToString(), notificationInfo.GetDataValue(NotificationProviderMailingConsts.NotificationInfoBodyPropertyName).ToString()); await SaveNotificationResultAsync(notification, true); }