Skip to content

Commit

Permalink
Merge pull request #999 from bcgov/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jimmyPasta authored Jan 14, 2025
2 parents 0f93711 + b00c109 commit af59577
Show file tree
Hide file tree
Showing 17 changed files with 1,101 additions and 1,011 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CreateUpdateApplicantInfoDto : CustomDataFieldDto
public string? SubSector { get; set; }
public string? SectorSubSectorIndustryDesc { get; set; } = string.Empty;
public bool? RedStop { get; set; }

public string? IndigenousOrgInd { get; set; }
public string? ContactFullName { get; set; }
public string? ContactTitle { get; set; }
public string? ContactEmail { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public class GrantApplicationApplicantDto : AuditedEntityDto<Guid>
public string OrganizationSize { get; set; } = string.Empty;
public string SectorSubSectorIndustryDesc { get; set; } = string.Empty;
public bool RedStop { get; set; } = false;
public string IndigenousOrgInd { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public interface IApplicationLinksService : ICrudAppService<
Guid>
{
Task<List<ApplicationLinksInfoDto>> GetListByApplicationAsync(Guid applicationId);

Task<ApplicationLinksInfoDto> GetLinkedApplicationAsync(Guid currentApplicationId, Guid linkedApplicationId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ private async Task<Applicant> CreateNewApplicantAsync(IntakeMapping intakeMap)
SubSector = intakeMap.SubSector,
SectorSubSectorIndustryDesc = intakeMap.SectorSubSectorIndustryDesc,
ApproxNumberOfEmployees = intakeMap.ApproxNumberOfEmployees,
IndigenousOrgInd = intakeMap.IndigenousOrgInd ?? "N",
IndigenousOrgInd = intakeMap.IndigenousOrgInd,
OrgStatus = intakeMap.OrgStatus,
RedStop = false
RedStop = false,
};

return await applicantRepository.InsertAsync(applicant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public async Task<ApplicationApplicantInfoDto> GetByApplicationIdAsync(Guid appl
SectorSubSectorIndustryDesc = applicantInfo.Applicant?.SectorSubSectorIndustryDesc ?? string.Empty,
SubSector = applicantInfo.Applicant?.SubSector ?? string.Empty,
RedStop = applicantInfo.Applicant?.RedStop ?? false,
IndigenousOrgInd = applicantInfo.Applicant?.IndigenousOrgInd ?? string.Empty,

SigningAuthorityBusinessPhone = applicantInfo.SigningAuthorityBusinessPhone ?? string.Empty,
SigningAuthorityCellPhone = applicantInfo.SigningAuthorityCellPhone ?? string.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,29 @@ join appForm in applicationFormsQuery on application.ApplicationFormId equals ap

return await combinedQuery.ToListAsync();
}

public async Task<ApplicationLinksInfoDto> GetLinkedApplicationAsync(Guid currentApplicationId, Guid linkedApplicationId)
{
var applicationLinksQuery = await ApplicationLinksRepository.GetQueryableAsync();
var applicationsQuery = await ApplicationRepository.GetQueryableAsync();
var applicationFormsQuery = await ApplicationFormRepository.GetQueryableAsync();

var combinedQuery = from applicationLinks in applicationLinksQuery
join application in applicationsQuery on applicationLinks.LinkedApplicationId equals application.Id into appLinks
from application in appLinks.DefaultIfEmpty() // Left join for safety
join appForm in applicationFormsQuery on application.ApplicationFormId equals appForm.Id into appForms
from appForm in appForms.DefaultIfEmpty() // Left join for safety
where applicationLinks.ApplicationId == linkedApplicationId && applicationLinks.LinkedApplicationId == currentApplicationId
select new ApplicationLinksInfoDto
{
Id = applicationLinks.Id,
ApplicationId = application.Id,
ApplicationStatus = application.ApplicationStatus.InternalStatus,
ReferenceNumber = application.ReferenceNo,
Category = appForm.Category ?? "Unknown", // Handle potential nulls
ProjectName = application.ProjectName
};

return await combinedQuery.SingleAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ public async Task<GrantApplicationDto> UpdateProjectApplicantInfoAsync(Guid id,
applicant.Sector = input.Sector ?? "";
applicant.SubSector = input.SubSector ?? "";
applicant.SectorSubSectorIndustryDesc = input.SectorSubSectorIndustryDesc ?? "";
applicant.IndigenousOrgInd = input.IndigenousOrgInd ?? "";

_ = await _applicantRepository.UpdateAsync(applicant);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private async Task<string> FormatApplicantJsonAsync(Applicant? applicant)
FiscalYearMonth = applicant.FiscalMonth,
BusinessNumber = applicant.BusinessNumber,
RedStop = applicant.RedStop,
IndigenousOrgInd = applicant.IndigenousOrgInd,
PhysicalAddressUnit = applicantPhysicalAgent?.Unit ?? "",
PhysicalAddressLine1 = applicantPhysicalAgent?.Street ?? "",
PhysicalAddressLine2 = applicantPhysicalAgent?.Street2 ?? "",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Collections.Immutable;

namespace Unity.GrantManager.GrantApplications;

public static class ApplicantInfoOptionsList
{
public static ImmutableDictionary<string, string> IndigenousList =>
ImmutableDictionary.CreateRange(new[]
{
new KeyValuePair<string, string>("Yes", "Yes"),
new KeyValuePair<string, string>("No", "No"),
});

}
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
"ApplicantInfoView:ApplicantInfo.OrgBookStatus": "Org book status ",
"ApplicantInfoView:ApplicantInfo.OrganizationType": "Organization Type",
"ApplicantInfoView:ApplicantInfo.OrganizationSize": "Organization Size",
"ApplicantInfoView:ApplicantInfo.IndigenousOrgInd": "Indigenous",
"ApplicantInfoView:ApplicantInfo.Sector": "Sector",
"ApplicantInfoView:ApplicantInfo.SubSector": "Sub-sector",
"ApplicantInfoView:ApplicantInfo.RedStop": "Red-Stop",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ApplicantResult
public string? FiscalYearMonth { get; set; } = string.Empty;
public string? BusinessNumber { get; set; } = string.Empty;
public bool? RedStop { get; set; }
public string? IndigenousOrgInd { 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class ApplicationLinksModalModel : AbpPageModel
[BindProperty]
public Guid? CurrentApplicationId { get; set; }


public ApplicationLinksModalModel(IApplicationLinksService applicationLinksService, IGrantApplicationAppService grantApplicationAppService)
{
_applicationLinksService = applicationLinksService ?? throw new ArgumentNullException(nameof(applicationLinksService));
Expand All @@ -62,18 +61,23 @@ public async Task OnGetAsync(Guid applicationId)
{
CurrentApplicationId = applicationId;
var grantApplications = await _grantApplicationAppService.GetAllApplicationsAsync();
var tempGrantApplications = new List<GrantApplicationLiteDto>(grantApplications);
var currentApplication = tempGrantApplications.Single(item => item.Id == applicationId);

var linkedApplications = await _applicationLinksService.GetListByApplicationAsync(applicationId);
var filteredLinkedApplications = linkedApplications.Where(item => item.ApplicationId != CurrentApplicationId);

// remove current application id from ths suggestion list
grantApplications.Remove(grantApplications.Single(item => item.Id == applicationId));
tempGrantApplications.Remove(currentApplication);

var formattedAllApplications = grantApplications.Select(item => item.ReferenceNo + " - " + item.ProjectName).ToList();
var formattedLinkedApplications = linkedApplications.Select(item => item.ReferenceNumber + " - " + item.ProjectName).ToList();
var formattedAllApplications = tempGrantApplications.Select(item => item.ReferenceNo + " - " + item.ProjectName).ToList();
var formattedLinkedApplications = filteredLinkedApplications.Select(item => item.ReferenceNumber + " - " + item.ProjectName).ToList();

AllApplications = string.Join(",", formattedAllApplications);
SelectedApplications = string.Join(",", formattedLinkedApplications);
GrantApplicationsList = JsonConvert.SerializeObject(grantApplications);
LinkedApplicationsList = JsonConvert.SerializeObject(linkedApplications);
LinkedApplicationsList = JsonConvert.SerializeObject(filteredLinkedApplications);

}
catch (Exception ex)
{
Expand All @@ -89,6 +93,7 @@ public async Task<IActionResult> OnPostAsync()
string[]? selectedApplicationsArray = JsonConvert.DeserializeObject<string[]>(SelectedApplications);
List<GrantApplicationLiteDto>? grantApplications = JsonConvert.DeserializeObject<List<GrantApplicationLiteDto>>(GrantApplicationsList!);
List<ApplicationLinksInfoDto>? linkedApplications = JsonConvert.DeserializeObject<List<ApplicationLinksInfoDto>>(LinkedApplicationsList!);
List<ApplicationLinksInfoDto>? applicationList = JsonConvert.DeserializeObject<List<ApplicationLinksInfoDto>>(GrantApplicationsList!);

foreach (var item in selectedApplicationsArray!)
{
Expand All @@ -100,10 +105,18 @@ public async Task<IActionResult> OnPostAsync()
if (applicationLinksInfoDto == null) {
Guid linkedApplicationId = grantApplications!.Find(application => application.ReferenceNo == referenceNo)!.Id;

//For CurrentApplication
await _applicationLinksService.CreateAsync(new ApplicationLinksDto{
ApplicationId = CurrentApplicationId ?? Guid.Empty,
LinkedApplicationId = linkedApplicationId
});

//For LinkedApplication
await _applicationLinksService.CreateAsync(new ApplicationLinksDto
{
ApplicationId = linkedApplicationId,
LinkedApplicationId = CurrentApplicationId ?? Guid.Empty
});
}
}

Expand All @@ -113,6 +126,9 @@ await _applicationLinksService.CreateAsync(new ApplicationLinksDto{
var selectedIndex = selectedApplicationsArray!.FindIndex(selected => selected.Split('-')[0].Trim() == linked.ReferenceNumber);
if(selectedIndex < 0) {
await _applicationLinksService.DeleteAsync(linked.Id);

var linkApp = await _applicationLinksService.GetLinkedApplicationAsync(CurrentApplicationId ?? Guid.Empty, linked.ApplicationId);
await _applicationLinksService.DeleteAsync(linkApp.Id);
}
}
}
Expand Down
Loading

0 comments on commit af59577

Please sign in to comment.