示例#1
0
        private async System.Threading.Tasks.Task SendEmailNotification(SubmissionTemplateType notificationType, string email, string name, IEnumerable <KeyValuePair <string, string> > tokens)
        {
            var template = (EmailTemplate)await templateProviderResolver.Resolve(NotificationChannelType.Email).Get(notificationType);

            var emailContent = (await transformator.Transform(new TransformationData
            {
                Template = template.Content,
                Tokens = new Dictionary <string, string>(tokens)
            })).Content;

            await notificationSender.Send(new EmailNotification
            {
                Subject = template.Subject,
                Content = emailContent,
                To      = new[] { new EmailAddress {
                                      Name = name, Address = email
                                  } }
            });
        }
 /// <summary>Transforms the specified source instance into single destination instance without specifying the initial destination instance.</summary>
 /// <typeparam name="TSource">Source data type to transform from.</typeparam>
 /// <typeparam name="TDestination">Destination data type to transform to.</typeparam>
 /// <param name="transformator">Transformator to apply the extension to.</param>
 /// <param name="source">Source instance to transform.</param>
 /// <param name="context">Transformation context.</param>
 /// <returns>Single destination instance.</returns>
 public static TDestination Transform <TSource, TDestination>(this ITransformator <TSource, TDestination> transformator, TSource source,
                                                              TransformationContext context = null)
 {
     return(transformator.Transform(source, context: context));
 }