public async Task <IActionResult> SendNonce(string identifier) { try { // create a nonce/token pair, store them, get Nonce var nonce = await _authService.CreateAndStoreNonce(identifier); // run the BeforeSendingNonce action, discard result await _actionService.BeforeSendingNonce(identifier); // create body for message to be sent to user & send it var body = _templateProcessor.ProcessTemplate(nonce); await _senderService.SendAsync(identifier, body); _logger.LogDebug($"A message was sent to: {identifier}. It contained the body: {body}."); return(Ok($"Success! Sent Nonce to: {identifier}.")); } catch (InvalidIdentifierException e) { _logger.LogError(e.ToString()); return(BadRequest("Identifier invalid.")); } catch (Exception e) { _logger.LogError(e.ToString()); return(BadRequest("Something went wrong.")); } }
public async Task Run( [ServiceBusTrigger("%smsQueueName%", Connection = "ServiceBusConnection")] string smsQueueItem, ILogger logger) { logger.LogInformation($"{nameof(HandleSms)} function starts."); var smsDto = JsonConvert.DeserializeObject <SmsDto>(smsQueueItem); await _senderService.SendAsync(smsDto); logger.LogInformation($"{nameof(HandleSms)} function ends."); }
public async Task RunAsync( [ServiceBusTrigger("%emailQueueName%", Connection = "ServiceBusConnection")] string queueMessage, ILogger logger) { logger.LogInformation($"{nameof(HandleEmails)} function starts."); logger.LogInformation($"Email to send as JSON: {queueMessage}."); var emailDto = JsonConvert.DeserializeObject <EmailDto>(queueMessage); var email = _emailBuilderFactory .Create(emailDto.Type) .GetMessage(emailDto); await _emailSenderService.SendAsync(email); logger.LogInformation($"{nameof(HandleEmails)} function ends."); }