-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNotificationsDataSeedContributor.cs
More file actions
66 lines (59 loc) · 3.69 KB
/
NotificationsDataSeedContributor.cs
File metadata and controls
66 lines (59 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.Notifications.Templates;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
namespace Unity.Notifications;
public class NotificationsDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly ITemplateVariablesRepository _templateVariablesRepository;
public NotificationsDataSeedContributor(ITemplateVariablesRepository templateVariablesRepository)
{
_templateVariablesRepository = templateVariablesRepository;
}
public async Task SeedAsync(DataSeedContext context)
{
if (context.TenantId == null) // only seed into a tenant database
{
return;
}
var emailTemplateVariableDtos = new List<EmailTempateVariableDto>
{
new EmailTempateVariableDto { Name = "Applicant name", Token = "applicant_name", MapTo = "applicant.applicantName" },
new EmailTempateVariableDto { Name = "Submission #", Token = "submission_number", MapTo = "referenceNo" },
new EmailTempateVariableDto { Name = "Submission Date", Token = "submission_date", MapTo = "submissionDate" },
new EmailTempateVariableDto { Name = "Category", Token = "category", MapTo = "applicationForm.category" },
new EmailTempateVariableDto { Name = "Status", Token = "status", MapTo = "status" },
new EmailTempateVariableDto { Name = "Approved Amount", Token = "approved_amount", MapTo = "approvedAmount" },
new EmailTempateVariableDto { Name = "Approval date", Token = "approval_date", MapTo = "finalDecisionDate" },
new EmailTempateVariableDto { Name = "Community", Token = "community", MapTo = "community" },
new EmailTempateVariableDto { Name = "Contact Full Name", Token = "contact_full_name", MapTo = "contactFullName" },
new EmailTempateVariableDto { Name = "Contact Title", Token = "contact_title", MapTo = "contactTitle" },
new EmailTempateVariableDto { Name = "Decline Rationale", Token = "decline_rationale", MapTo = "declineRational" },
new EmailTempateVariableDto { Name = "Registered Organization Name", Token = "organization_name", MapTo = "organizationName" },
new EmailTempateVariableDto { Name = "Project Start Date", Token = "project_start_date", MapTo = "projectStartDate" },
new EmailTempateVariableDto { Name = "Project End Date", Token = "project_end_date", MapTo = "projectEndDate" },
new EmailTempateVariableDto { Name = "Project Name", Token = "project_name", MapTo = "projectName" },
new EmailTempateVariableDto { Name = "Project Summary", Token = "project_summary", MapTo = "projectSummary" },
new EmailTempateVariableDto { Name = "Signing Authority Full Name", Token = "signing_authority_full_name", MapTo = "signingAuthorityFullName" },
new EmailTempateVariableDto { Name = "Signing Authority Title", Token = "signing_authority_title", MapTo = "signingAuthorityTitle" }
};
foreach (var template in emailTemplateVariableDtos)
{
var existingVariable = await _templateVariablesRepository.FindAsync(tv => tv.Token == template.Token);
if (existingVariable == null)
{
await _templateVariablesRepository.InsertAsync(
new TemplateVariable { Name = template.Name, Token = template.Token, MapTo = template.MapTo },
autoSave: true
);
}
}
}
}
internal class EmailTempateVariableDto
{
public string Name { get; set; } = string.Empty;
public string Token { get; set; } = string.Empty;
public string MapTo { get; set; } = string.Empty;
}