コード例 #1
0
ファイル: SearchResultService.cs プロジェクト: bcgov/fams3
        private async Task <bool> UploadInsuranceClaims()
        {
            if (_foundPerson.InsuranceClaims == null)
            {
                return(true);
            }
            try
            {
                _logger.LogDebug($"Attempting to create insurance claims records for SearchRequest[{_searchRequest.SearchRequestId}]");

                foreach (InsuranceClaim claim in _foundPerson.InsuranceClaims)
                {
                    ICBCClaimEntity icbcClaim = _mapper.Map <ICBCClaimEntity>(claim);
                    icbcClaim.SearchRequest     = _searchRequest;
                    icbcClaim.InformationSource = _providerDynamicsID;
                    icbcClaim.Person            = _returnedPerson;
                    SSG_Asset_ICBCClaim ssg_claim = await _searchRequestService.CreateInsuranceClaim(icbcClaim, _cancellationToken);
                    await CreateResultTransaction(ssg_claim);

                    if (claim.ClaimCentre != null && claim.ClaimCentre.ContactNumber != null)
                    {
                        foreach (Phone phone in claim.ClaimCentre.ContactNumber)
                        {
                            SimplePhoneNumberEntity phoneForAsset = _mapper.Map <SimplePhoneNumberEntity>(phone);
                            phoneForAsset.SSG_Asset_ICBCClaim = ssg_claim;
                            await _searchRequestService.CreateSimplePhoneNumber(phoneForAsset, _cancellationToken);
                        }
                    }

                    if (claim.InsuredParties != null)
                    {
                        foreach (InvolvedParty party in claim.InsuredParties)
                        {
                            InvolvedPartyEntity involvedParty = _mapper.Map <InvolvedPartyEntity>(party);
                            involvedParty.SSG_Asset_ICBCClaim = ssg_claim;
                            await _searchRequestService.CreateInvolvedParty(involvedParty, _cancellationToken);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogException(ex);
                return(false);
            }
        }