private async Task <CivilAdjudicator> PopulateDetailedAppearanceAdjudicator(CvfcPreviousAppearance previousAppearance, ICollection <JCCommon.Clients.FileServices.CivilAppearanceMethod> civilAppearanceMethods) { if (previousAppearance == null) { return(null); } var appearanceMethodCd = civilAppearanceMethods.FirstOrDefault(am => am.RoleTypeCd == "ADJ")?.AppearanceMethodCd; return(new CivilAdjudicator { FullName = previousAppearance.AdjudicatorName, AdjudicatorAppearanceMethod = previousAppearance.AdjudicatorAppearanceMethod, AdjudicatorAppearanceMethodDesc = await _lookupService.GetCivilAssetsDescription(previousAppearance.AdjudicatorAppearanceMethod), AppearanceMethodCd = appearanceMethodCd, AppearanceMethodDesc = await _lookupService.GetCivilAssetsDescription(appearanceMethodCd) }); }
/// <summary> /// This is mostly based off of getAppearanceCivilParty and expands by court list and FileContent. /// </summary> private async Task <ICollection <CivilAppearanceDetailParty> > PopulateDetailedAppearancePartiesAsync(ICollection <CivilAppearanceParty> parties, ICollection <ClParty> courtListParties, CvfcPreviousAppearance previousAppearance, ICollection <JCCommon.Clients.FileServices.CivilAppearanceMethod> civilAppearanceMethods) { var resultParties = new List <CivilAppearanceDetailParty>(); foreach (var partyGroup in parties.GroupBy(a => a.PartyId)) { //Map over our primary values from party group. var party = _mapper.Map <CivilAppearanceDetailParty>(partyGroup.First()); //Get our roles from getAppearanceCivilParty. These should essentially be the same. party.PartyRole = await partyGroup.Select(async pg => new ClPartyRole { RoleTypeCd = pg.PartyRoleTypeCd, RoleTypeDsc = await _lookupService.GetCivilRoleTypeDescription(pg.PartyRoleTypeCd) }).WhenAll(); //Get information from appearanceMethods. if (civilAppearanceMethods.Any(am => party.PartyRole.Any(pr => pr.RoleTypeCd == am.RoleTypeCd))) { party.AppearanceMethodCd = civilAppearanceMethods.First().AppearanceMethodCd; party.AppearanceMethodDesc = await _lookupService.GetCivilAssetsDescription(civilAppearanceMethods.First().AppearanceMethodCd); } //Get the additional information from court list. var courtListParty = courtListParties?.FirstOrDefault(clp => clp.PartyId == partyGroup.Key); if (courtListParty != null) { party.AttendanceMethodCd = courtListParty.AttendanceMethodCd; party.AttendanceMethodDesc = await _lookupService.GetCivilAssetsDescription(party.AttendanceMethodCd); party.Counsel = _mapper.Map <ICollection <CivilCounsel> >(courtListParty.Counsel); party.Representative = _mapper.Map <ICollection <CivilRepresentative> >(courtListParty.Representative); foreach (var representative in party.Representative) { representative.AttendanceMethodDesc = await _lookupService.GetCivilAssetsDescription(representative.AttendanceMethodCd); } party.LegalRepresentative = courtListParty.LegalRepresentative; } //Add additional information from previous appearance - this comes from FileContent. if (previousAppearance?.CourtParticipant != null && previousAppearance.CourtParticipant.Any(cp => cp.PartId == party.PartyId)) { //Can be multiple rows here, but they repeat for the partyRole. var targetParticipant = previousAppearance.CourtParticipant.First(cp => cp.PartId == party.PartyId); party.PartyAppearanceMethod = targetParticipant.PartyAppearanceMethod; party.PartyAppearanceMethodDesc = await _lookupService.GetCivilPartyAttendanceType(targetParticipant.PartyAppearanceMethod); //Update the counsel with their appearanceMethod. foreach (var counsel in targetParticipant.Counsel) { //We match on counselName. //Not the best idea of matching data, but we aren't provided a counselId for Civil FileContent. Although we are provided a counselId in FileDetails, CourtList. //TEST Environment - Civil Case 2151 - Appearance 9042, demonstrates this. if (!counsel.AdditionalProperties.ContainsKey("counselName")) { continue; } var targetCounsel = party.Counsel?.FirstOrDefault(c => c.CounselFullName == counsel.CounselName); if (targetCounsel == null) { continue; } targetCounsel.CounselAppearanceMethod = counsel.CounselAppearanceMethod; targetCounsel.CounselAppearanceMethodDesc = await _lookupService.GetCivilCounselAttendanceType(targetCounsel.CounselAppearanceMethod); } } resultParties.Add(party); } return(resultParties); }