Skip to content
Merged

Test #893

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ private async Task<string> FormatApplicantJsonAsync(Applicant? applicant)
string bcSocietyNumber = applicant.OrgNumber?.StartsWith('S') == true ? applicant.OrgNumber : string.Empty;

// Fetch address and agent information
List<ApplicantAddress> applicantAddresses = await applicantAddressRepository.FindByApplicantIdAsync(applicant.Id);
ApplicantAddress? applicantAddress = applicantAddresses?.FirstOrDefault();
// Fetch all applicant addresses at once
List<ApplicantAddress>? applicantAddresses = await applicantAddressRepository.FindByApplicantIdAsync(applicant.Id);

// Order by date (for example, DateCreated) in descending order
applicantAddresses = applicantAddresses?.OrderByDescending(x => x.LastModificationTime).ToList();

// Filter physical and mailing addresses from the sorted list
ApplicantAddress? applicantPhysicalAgent = applicantAddresses?.Find(x => x.AddressType == GrantApplications.AddressType.PhysicalAddress);
ApplicantAddress? applicantMailingAgent = applicantAddresses?.Find(x => x.AddressType == GrantApplications.AddressType.MailingAddress);

ApplicantAgent? applicantAgent = await applicantAgentRepository.FirstOrDefaultAsync(x => x.ApplicantId == applicant.Id);

var result = new ApplicantResult
Expand All @@ -94,13 +102,20 @@ private async Task<string> FormatApplicantJsonAsync(Applicant? applicant)
FiscalYearDay = applicant.FiscalDay.ToString(),
FiscalYearMonth = applicant.FiscalMonth,
BusinessNumber = applicant.BusinessNumber,
PyhsicalAddressUnit = applicantAddress?.Unit ?? "",
PyhsicalAddressLine1 = applicantAddress?.Street ?? "",
PyhsicalAddressLine2 = applicantAddress?.Street2 ?? "",
PyhsicalAddressPostal = applicantAddress?.Postal ?? "",
PyhsicalAddressCity = applicantAddress?.City ?? "",
PyhsicalAddressProvince = applicantAddress?.Province ?? "",
PyhsicalAddressCountry = applicantAddress?.Country ?? "",
PhysicalAddressUnit = applicantPhysicalAgent?.Unit ?? "",
PhysicalAddressLine1 = applicantPhysicalAgent?.Street ?? "",
PhysicalAddressLine2 = applicantPhysicalAgent?.Street2 ?? "",
PhysicalAddressPostal = applicantPhysicalAgent?.Postal ?? "",
PhysicalAddressCity = applicantPhysicalAgent?.City ?? "",
PhysicalAddressProvince = applicantPhysicalAgent?.Province ?? "",
PhysicalAddressCountry = applicantPhysicalAgent?.Country ?? "",
MailingAddressUnit = applicantMailingAgent?.Unit ?? "",
MailingAddressLine1 = applicantMailingAgent?.Street ?? "",
MailingAddressLine2 = applicantMailingAgent?.Street2 ?? "",
MailingAddressPostal = applicantMailingAgent?.Postal ?? "",
MailingAddressCity = applicantMailingAgent?.City ?? "",
MailingAddressProvince = applicantMailingAgent?.Province ?? "",
MailingAddressCountry = applicantMailingAgent?.Country ?? "",
PhoneNumber = applicantAgent?.Phone ?? "",
PhoneExtension = applicantAgent?.PhoneExtension ?? ""
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ public class ApplicantResult
public string? FiscalYearDay { get; set; } = string.Empty;
public string? FiscalYearMonth { get; set; } = string.Empty;
public string? BusinessNumber { get; set; } = string.Empty;
public string? PyhsicalAddressUnit { get; set; } = string.Empty;
public string? PyhsicalAddressLine1 { get; set; } = string.Empty;
public string? PyhsicalAddressLine2 { get; set; } = string.Empty;
public string? PyhsicalAddressPostal { get; set; } = string.Empty;
public string? PyhsicalAddressCity { get; set; } = string.Empty;
public string? PyhsicalAddressProvince { get; set; } = string.Empty;
public string? PyhsicalAddressCountry { get; set; } = string.Empty;
public string? PhysicalAddressUnit { get; set; } = string.Empty;
public string? PhysicalAddressLine1 { get; set; } = string.Empty;
public string? PhysicalAddressLine2 { get; set; } = string.Empty;
public string? PhysicalAddressPostal { get; set; } = string.Empty;
public string? PhysicalAddressCity { get; set; } = string.Empty;
public string? PhysicalAddressProvince { get; set; } = string.Empty;
public string? PhysicalAddressCountry { get; set; } = string.Empty;
public string? MailingAddressUnit { get; set; } = string.Empty;
public string? MailingAddressLine1 { get; set; } = string.Empty;
public string? MailingAddressLine2 { get; set; } = string.Empty;
public string? MailingAddressPostal { get; set; } = string.Empty;
public string? MailingAddressCity { get; set; } = string.Empty;
public string? MailingAddressProvince { get; set; } = string.Empty;
public string? MailingAddressCountry { get; set; } = string.Empty;
public string? PhoneNumber { get; set; } = string.Empty;
public string? PhoneExtension { get; set; } = string.Empty;
}
Expand Down