public async Task <SSG_AgencyLocation> GetSearchAgencyLocation(string locationCode, string agencyCode, CancellationToken cancellationToken) { try { SSG_AgencyLocation officeLocation = null; if (locationCode?.Length > 5) { //temp, as the sample files is not changed to code yet. so, if it is not code, run following code. //We just currently use City as temp solution. expecting FMEP will provide office code later string officeLocationCity = locationCode.Split(",")[1].Trim(); officeLocation = await _oDataClient.For <SSG_AgencyLocation>() .Filter(x => x.City == officeLocationCity) .FindEntryAsync(cancellationToken); } else { //it is code, like B,R,C,K officeLocation = await _oDataClient.For <SSG_AgencyLocation>() .Filter(x => x.AgencyCode == agencyCode && x.LocationCode == locationCode) .FindEntryAsync(cancellationToken); } return(officeLocation); } catch (Exception) { return(null); } }
private async Task <bool> UpdateSearchRequest(SearchRequestEntity newSR) { string originNotes = _uploadedSearchRequest.Notes; SSG_SearchRequest clonedSR = _uploadedSearchRequest.Clone(); Dictionary <string, object> updatedFields = (Dictionary <string, object>)clonedSR.GetUpdateEntries(newSR); if (newSR.SearchReasonCode != null && !newSR.SearchReasonCode.Equals(_uploadedSearchRequest.SearchReason?.ReasonCode, StringComparison.InvariantCultureIgnoreCase)) { SSG_SearchRequestReason reason = await _searchRequestService.GetSearchReason(newSR.SearchReasonCode, _cancellationToken); updatedFields.Add("ssg_RequestCategoryText", reason); } if (newSR.AgencyOfficeLocationText != null && !newSR.AgencyOfficeLocationText.Equals(_uploadedSearchRequest.AgencyLocation.LocationCode, StringComparison.InvariantCultureIgnoreCase)) { SSG_AgencyLocation location = await _searchRequestService.GetSearchAgencyLocation( newSR.AgencyOfficeLocationText, newSR.AgencyCode, _cancellationToken); updatedFields.Add("ssg_AgencyLocation", location); } //comment out this as even there is nothing needed to change, we still need to set ssg_updatedbyagency to true to //trigger the Dynamics to send out the estimation date notification. //if (updatedFields.Count > 0) //except notes, there is something else changed. //{ await _searchRequestService.UpdateSearchRequest(_uploadedSearchRequest.SearchRequestId, updatedFields, _cancellationToken); _logger.LogInformation("Update Search Request successfully"); //} return(true); }