Example #1
0
        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);
        }