示例#1
0
        public override void PopulateMessage(EmailRequest request, ISendGrid message)
        {
            var sendgridToken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.EmployerApplicationLinks);

            var applicationLinksJson = request.Tokens.Single(t => t.Key == CommunicationTokens.EmployerApplicationLinks).Value;
            var applicationLinks     = JsonConvert.DeserializeObject <Dictionary <string, string> >(applicationLinksJson) ?? new Dictionary <string, string>();

            var linksStringBuilder = new StringBuilder("<ul>");

            foreach (var applicationLink in applicationLinks)
            {
                linksStringBuilder.Append($"<li><a href=\"https://{_siteDomainName}{applicationLink.Value}\">{applicationLink.Key}</a></li>");
            }
            linksStringBuilder.Append("</ul>");

            message.AddSubstitution(sendgridToken, new List <string> {
                linksStringBuilder.ToString()
            });

            var tokens = new List <CommunicationTokens> {
                CommunicationTokens.ApplicationVacancyTitle, CommunicationTokens.ProviderName, CommunicationTokens.EmployerApplicationLinksExpiry
            };

            foreach (var token in request.Tokens.Where(t => tokens.Contains(t.Key)))
            {
                var sendgridtoken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(token.Key);

                message.AddSubstitution(sendgridtoken,
                                        new List <string>
                {
                    token.Value
                });
            }
        }
 private static void AddSubstitutionTo(ISendGrid message, string sendgridtoken, string substitutionText)
 {
     message.AddSubstitution(
         sendgridtoken,
         new List <string>
     {
         substitutionText
     });
 }
示例#3
0
 public override void PopulateMessage(EmailRequest request, ISendGrid message)
 {
     foreach (var token in request.Tokens)
     {
         var sendgridtoken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(token.Key);
         message.AddSubstitution(sendgridtoken,
                                 new List <string>
         {
             token.Value
         });
     }
 }
示例#4
0
 private void AddSubstitutionTo(ISendGrid message, string replacementTag, string value)
 {
     message.AddSubstitution(replacementTag, new List <string> {
         value
     });
 }