Example #1
0
        private void PopulateCandidateName(EmailRequest request, ISendGrid message)
        {
            var token = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.CandidateFirstName);
            var value = request.Tokens.First(t => t.Key == CommunicationTokens.CandidateFirstName).Value;

            AddSubstitutionTo(message, token, value);
        }
Example #2
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
                });
            }
        }
Example #3
0
        private static void PopulateFullName(EmailRequest request, ISendGrid message)
        {
            var candidateFirstNameToken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.FullName);

            var substitutionText = request.Tokens.First(t => t.Key == CommunicationTokens.FullName).Value;

            AddSubstitutionTo(message, candidateFirstNameToken, substitutionText);
        }
Example #4
0
        private void PopulateSavedSearchAlerts(EmailRequest request, ISendGrid message)
        {
            var token = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.SavedSearchAlerts);
            var value = request.Tokens.First(t => t.Key == CommunicationTokens.SavedSearchAlerts).Value;

            var json = TransformTokenValueToJson(value);
            var html = TransformJsonToHtml(json);

            AddSubstitutionTo(message, token, html);
        }
        private static void PopulateItemCountData(EmailRequest request, ISendGrid message)
        {
            var itemCountToken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.ExpiringDraftsCount);

            var itemCount = Convert.ToInt32(request.Tokens.First(t => t.Key == CommunicationTokens.ExpiringDraftsCount).Value);

            var substitutionText = itemCount == 1 ? OneSavedApplicationAboutToExpire : MoreThanOneSaveApplicationAboutToExpire;

            AddSubstitutionTo(message, itemCountToken, substitutionText);
        }
        private void PopulateApplicationStatusAlerts(EmailRequest request, ISendGrid message)
        {
            var sendgridToken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.ApplicationStatusAlerts);

            var alertsJson = request.Tokens.First(t => t.Key == CommunicationTokens.ApplicationStatusAlerts).Value;
            var alerts     = JsonConvert.DeserializeObject <List <ApplicationStatusAlert> >(alertsJson) ?? new List <ApplicationStatusAlert>();

            var substitutionText = GetApplicationStatusAlertsInfoSubstitution(alerts);

            AddSubstitutionTo(message, sendgridToken, substitutionText);
        }
Example #7
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
         });
     }
 }
Example #8
0
        private void PopulateUnsubscribe(EmailRequest request, ISendGrid message)
        {
            {
                var token = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.CandidateSubscriberId);
                var value = request.Tokens.First(t => t.Key == CommunicationTokens.CandidateSubscriberId).Value;

                AddSubstitutionTo(message, token, value);
            }

            {
                var token = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.CandidateSubscriptionType);
                var value = request.Tokens.First(t => t.Key == CommunicationTokens.CandidateSubscriptionType).Value;

                AddSubstitutionTo(message, token, value);
            }
        }
        private void PopulateExpiringDrafts(EmailRequest request, ISendGrid message)
        {
            var stringBuilder = new StringBuilder();

            var draftsJson = request.Tokens.First(t => t.Key == CommunicationTokens.ExpiringDrafts).Value;
            var drafts     = JsonConvert.DeserializeObject <List <ExpiringApprenticeshipApplicationDraft> >(draftsJson) ?? new List <ExpiringApprenticeshipApplicationDraft>();

            stringBuilder.Append(GetExpiringDraftsItemCountData(drafts));

            PopulateVacanciesDataSubstitution(drafts, stringBuilder);

            var sendgridToken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.ExpiringDrafts);

            var substitutionText = stringBuilder.ToString();

            AddSubstitutionTo(message, sendgridToken, substitutionText);
        }
Example #10
0
        private void PopulateSiteDomainName(ISendGrid message)
        {
            var token = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.CandidateSiteDomainName);

            AddSubstitutionTo(message, token, _siteDomainName);
        }
        private static void PopulateHtmlData(EmailRequest request, ISendGrid message)
        {
            var sendgridtoken = SendGridTokenManager.GetEmailTemplateTokenForCommunicationToken(CommunicationTokens.ExpiringDrafts);

            AddVacanciesDataSubstitution(request, message, sendgridtoken);
        }