Пример #1
0
        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."));
            }
        }
Пример #2
0
        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.");
        }
Пример #3
0
        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.");
        }