private Dictionary <string, object> GetTemplateData(NewJumpStart newJumpStart) { return(new Dictionary <string, object> { { "subject", $"Project Blue Delta - {newJumpStart.DateTime:MMMM d, yyyy}" }, { "date", newJumpStart.DateTime.ToString("dddd | MMM. d, yyyy") }, //{"to", newJumpStart.Status}, { "description", newJumpStart.Body ?? string.Empty } }); }
public NewJumpStartResult(NewJumpStart newJumpStart) { Id = newJumpStart.Id; Subject = newJumpStart.Subject; DateTime = newJumpStart.DateTime; DistributionGroups = newJumpStart.DistributionGroups; Tags = newJumpStart.Tags; Body = newJumpStart.Body; PdfUrl = newJumpStart.PdfUrl; }
private NewJumpStart Map(NewJumpStart newJumpStart, NewJumpStartModel model) { newJumpStart.DateTime = model.DateTime !.Value; newJumpStart.Subject = model.Subject; newJumpStart.DistributionGroups = model.DistributionGroups; newJumpStart.Tags = model.Tags; newJumpStart.Body = model.Body; newJumpStart.PdfUrl = model.PdfUrl; return(newJumpStart); }
private async Task SendEmailAsync(NewJumpStart newJumpStart) { var emailRecipients = await GetRecipientsAsync(newJumpStart.Id); var emailInfo = await GetEmailInfoAsync(newJumpStart, emailRecipients); await _sendGridService.SendEmailAsync(emailInfo); foreach (var emailRecipient in emailRecipients) { emailRecipient.Status = EmailStatus.Sent; } await _dbContext.SaveChangesAsync(); }
private async Task <EmailInfo> GetEmailInfoAsync(NewJumpStart newJumpStart, List <Data.Entity.Models.Email> emails) { var company = await _dbContext.Companies.FirstOrDefaultAsync(item => item.Name == VolkswagenCompany.Slug); var result = new EmailInfo(company.Id, emails) { TemplateKey = TemplateKey, TemplateData = GetTemplateData(newJumpStart), }; if (newJumpStart.PdfUrl != null) { var attachmentContent = await GetPdfContentAsync(newJumpStart.PdfUrl); result.AttachmentName = $"{newJumpStart.DateTime.Date:yyyy_MM_dd}.pdf"; result.AttachmentBase64Content = attachmentContent; } return(result); }