-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathContactInfoDataProvider.cs
More file actions
50 lines (42 loc) · 1.92 KB
/
ContactInfoDataProvider.cs
File metadata and controls
50 lines (42 loc) · 1.92 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
using System.Threading.Tasks;
using Unity.GrantManager.ApplicantProfile.ProfileData;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
namespace Unity.GrantManager.ApplicantProfile
{
/// <summary>
/// Provides contact information for the applicant profile by aggregating
/// profile-linked contacts, application-level contacts, and applicant agent contacts.
/// </summary>
[ExposeServices(typeof(IApplicantProfileDataProvider))]
public class ContactInfoDataProvider(
ICurrentTenant currentTenant,
IApplicantProfileContactService applicantProfileContactService)
: IApplicantProfileDataProvider, ITransientDependency
{
/// <inheritdoc />
public string Key => ApplicantProfileKeys.ContactInfo;
/// <inheritdoc />
public async Task<ApplicantProfileDataDto> GetDataAsync(ApplicantProfileInfoRequest request)
{
var dto = new ApplicantContactInfoDto
{
Contacts = []
};
var tenantId = request.TenantId;
using (currentTenant.Change(tenantId))
{
var profileContacts = await applicantProfileContactService.GetProfileContactsAsync(request.ProfileId);
dto.Contacts.AddRange(profileContacts);
var normalizedSubject = request.Subject.Contains('@')
? request.Subject[..request.Subject.IndexOf('@')].ToUpperInvariant()
: request.Subject.ToUpperInvariant();
var applicationContacts = await applicantProfileContactService.GetApplicationContactsBySubjectAsync(normalizedSubject);
dto.Contacts.AddRange(applicationContacts);
var agentContacts = await applicantProfileContactService.GetApplicantAgentContactsBySubjectAsync(normalizedSubject);
dto.Contacts.AddRange(agentContacts);
}
return dto;
}
}
}