public async Task Handle(Messages.Commands.SendEmailCommand message, IMessageHandlerContext context)
        {
            try
            {
                var command = new SendEmailMediatRCommand {
                    TemplateId        = message.TemplateId,
                    RecipientsAddress = message.RecipientsAddress,
                    Tokens            = message.Tokens.ToDictionary(e => e.Key, e => e.Value)
                };

                await _mediator.Send(command);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                throw;
            }
        }
Exemple #2
0
        public void Arrange()
        {
            _templateConfiguration = new TemplateConfiguration
            {
                EmailServiceTemplates = new List <Template>
                {
                    new Template {
                        Id = TemplateName, EmailServiceId = TranslatedTemplateId
                    },
                    new Template {
                        Id = "Not" + TemplateName, EmailServiceId = "fffb72dd-ef2d-4fcd-9d41-12a23801a5ea"
                    }
                }
            };

            _emailService = new Mock <IEmailService>();

            _handler = new SendEmailMediatRCommandHandler(
                Mock.Of <ILogger <SendEmailMediatRCommandHandler> >(),
                _emailService.Object,
                _templateConfiguration);

            _templateId        = Guid.NewGuid().ToString();
            _systemId          = "Test System";
            _subject           = "Test Email";
            _recipientsAddress = "*****@*****.**";
            _replyToAddress    = "*****@*****.**";
            _tokens            = new Dictionary <string, string> {
                { "Key1", "Value1" }
            };

            _command = new SendEmailMediatRCommand
            {
                RecipientsAddress = _recipientsAddress,
                TemplateId        = _templateId,
                Tokens            = _tokens
            };
        }