public void SendSmsMessage(Guid id) { var smsMessage = _repository.GetAll().FirstOrDefault(x => x.Id == id); if (smsMessage != null && !smsMessage.SentDateTime.HasValue) { try { _smsNotification.Send(smsMessage); _repository.UpdateSent(smsMessage.Id); } catch (Exception ex) { _repository.UpdateFailed(smsMessage.Id, Environment.NewLine + Environment.NewLine + ex.ToString()); } } }
public async Task SendSmsMessageAsync(Guid id) { var smsMessage = _repository.GetAll().FirstOrDefault(x => x.Id == id); if (smsMessage != null && !smsMessage.SentDateTime.HasValue) { try { await _smsNotification.SendAsync(new SmsMessageDTO { Message = smsMessage.Message, PhoneNumber = smsMessage.PhoneNumber, }); _repository.UpdateSent(smsMessage.Id); } catch (Exception ex) { _repository.UpdateFailed(smsMessage.Id, Environment.NewLine + Environment.NewLine + ex.ToString()); } } }