예제 #1
0
        private async Task <bool> UpdateRelatedApplicant(RelatedPersonEntity newApplicantEntity)
        {
            if (newApplicantEntity == null)
            {
                return(true);
            }

            //update or add relation relatedPerson
            SSG_Identity originalRelatedApplicant = _uploadedPerson.SSG_Identities?.FirstOrDefault(
                m => m.InformationSource == InformationSourceType.Request.Value &&
                m.PersonType == RelatedPersonPersonType.Applicant.Value);

            if (originalRelatedApplicant == null)
            {
                await UploadRelatedApplicant(newApplicantEntity.FirstName, newApplicantEntity.LastName);

                _logger.LogInformation("Create Related Applicant for SearchRequest successfully");
            }
            else
            {
                Dictionary <string, object> updatedFields = (Dictionary <string, object>)originalRelatedApplicant.Clone().GetUpdateEntries(newApplicantEntity);
                if (updatedFields.Count > 0)
                {
                    await _searchRequestService.UpdateRelatedPerson(originalRelatedApplicant.RelatedPersonId, updatedFields, _cancellationToken);

                    _logger.LogInformation("Update Related Applicant records for SearchRequest successfully");
                }
            }

            return(true);
        }