Example #1
0
        public async Task SendEmailAsync(IEmailBuildContext context, CancellationToken cancellationToken)
        {
            var builder = fEmailBuilderFactory.TryCreate(context);

            if (builder is null)
            {
                fLogger.LogError(context, $"For email build context of type '{context.GetType()}' doesn't exist any builder.");
                return;
            }

            var dto = await builder.TryBuildAsync(context, cancellationToken);

            if (dto is null)
            {
                fLogger.LogError(context, $"For email '{context.EmailType}' does not exist template in DB.");
                return;
            }

            await fEmailClient.SendEmailAsync(dto.RecipientAddress, dto.Subject, new EmailBody(dto.Body, dto.IsBodyHtml), context);
        }
Example #2
0
 public IEmailBuilder?TryCreate(IEmailBuildContext context)
 {
     return(GetComponents().SingleOrDefault(x => x.CanBuild(context)));
 }