public async Task <Email> RenderRemoteUsersUpdatedEmailAsync(RemoteUsersUpdatedEmailViewModel viewModel) { return(new Email ( from: PrimeEmail, to: new[] { MohEmail, PrimeSupportEmail }, subject: "Remote Practioners Added", body: await _razorConverterService.RenderTemplateToStringAsync(RazorTemplates.Emails.RemoteUsersUpdated, viewModel) )); }
public async Task SendRemoteUsersUpdatedAsync(Site site) { var downloadUrl = await _emailDocumentService.GetBusinessLicenceDownloadLink(site.Id); var viewModel = new RemoteUsersUpdatedEmailViewModel { SiteStreetAddress = site.PhysicalAddress.Street, OrganizationName = site.Organization.Name, SitePec = site.PEC, RemoteUserNames = site.RemoteUsers.Select(ru => $"{ru.FirstName} {ru.LastName}"), DocumentUrl = downloadUrl }; var email = await _emailRenderingService.RenderRemoteUsersUpdatedEmailAsync(viewModel); email.Attachments = await _emailDocumentService.GenerateSiteRegistrationSubmissionAttachmentsAsync(site.Id); await Send(email); }
public async void TestRender_RemoteUsersUpdatedEmail() { var service = CreateService(); var model = new RemoteUsersUpdatedEmailViewModel { SiteStreetAddress = "123 street", OrganizationName = "NAME", SitePec = "PecC", RemoteUserNames = new[] { "Alice", "bob bobward" }, DocumentUrl = "A.URL.com" }; var html = await service.RenderTemplateToStringAsync(RazorTemplates.Emails.RemoteUsersUpdated, model); Assert.NotNull(html); Assert.Contains(model.SiteStreetAddress, html); Assert.Contains(model.OrganizationName, html); Assert.Contains(model.SitePec, html); Assert.Contains(model.DocumentUrl, html); foreach (var name in model.RemoteUserNames) { Assert.Contains(name, html); } }