From 143416a460234435dfe6bbc9d9e50b624ba58522 Mon Sep 17 00:00:00 2001 From: Alan Leung Date: Wed, 19 Jun 2024 10:10:16 -0600 Subject: [PATCH] Fix issue (#2536) --- prime-dotnet-webapi/Services/PlrProviderService.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/prime-dotnet-webapi/Services/PlrProviderService.cs b/prime-dotnet-webapi/Services/PlrProviderService.cs index a35649888e..b245d26353 100644 --- a/prime-dotnet-webapi/Services/PlrProviderService.cs +++ b/prime-dotnet-webapi/Services/PlrProviderService.cs @@ -80,17 +80,21 @@ public async Task> GetMatchingPlrDataAsync(IEnumerable // Select PlrProviders that match a certification on both college AND license number .Where(p => _context.CollegeForPlrRoleTypes.Where(rt2c => rt2c.ProviderRoleType == p.ProviderRoleType).Select(rt2c => rt2c.CollegeCode).Contains(cert.CollegeCode) && p.CollegeId == cert.LicenseNumber) - .ProjectTo(_mapper.ConfigurationProvider, new { plrRoleTypes, plrStatusReasons }) .ToListAsync(); if (matches.Count > 0) { foreach (var match in matches) { + // Encountering problems with AutoMapper ProjectTo and existing data + PlrViewModel plrViewModel = _mapper.Map(match); + + plrViewModel.ProviderRoleType = await plrRoleTypes.Where(rt => rt.Code == match.ProviderRoleType).Select(rt => rt.Name).SingleAsync(); + plrViewModel.StatusReasonCode = await plrStatusReasons.Where(sr => sr.Code == match.StatusReasonCode).Select(rt => rt.Name).SingleAsync(); // If a PlrViewModel has ExpertiseCodes, translate the codes to human-readable text - // PlrProvider's Expertise array does not play well with automapper ProjectTo, map manually before return - match.Expertise = string.Join(", ", _context.Set().Where(e => - (match.ExpertiseCode != null && match.ExpertiseCode.Contains(e.Code))).Select(e => e.Name)); - plrProviders.Add(match); + plrViewModel.Expertise = string.Join(", ", _context.Set().Where(e => + plrViewModel.ExpertiseCode != null && plrViewModel.ExpertiseCode.Contains(e.Code)).Select(e => e.Name)); + + plrProviders.Add(plrViewModel); } } }