public async Task with_duplicated_insurance_not_contains_same_simplePhone_CreateSimplePhoneNumber_should_return_new_SSG_InvolvedParty()
        {
            _odataClientMock.Setup(x => x.For <SSG_SimplePhoneNumber>(null).Set(It.Is <SimplePhoneNumberEntity>(x => x.PhoneNumber == "notContain"))
                                   .InsertEntryAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_SimplePhoneNumber()
            {
                SimplePhoneNumberId = _testSimplePhoneId
            })
                     );
            _duplicateServiceMock.Setup(x => x.Exists(It.Is <SSG_Asset_ICBCClaim>(m => m.ICBCClaimId == _testId), It.Is <SimplePhoneNumberEntity>(m => m.PhoneNumber == "notContain")))
            .Returns(Task.FromResult(Guid.Empty));

            var phone = new SimplePhoneNumberEntity()
            {
                PhoneNumber         = "notContain",
                SSG_Asset_ICBCClaim = new SSG_Asset_ICBCClaim()
                {
                    IsDuplicated = true
                }
            };

            var result = await _sut.CreateSimplePhoneNumber(phone, CancellationToken.None);

            Assert.AreEqual(_testSimplePhoneId, result.SimplePhoneNumberId);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public async Task <SSG_SimplePhoneNumber> CreateSimplePhoneNumber(SimplePhoneNumberEntity phone, CancellationToken cancellationToken)
        {
            if (phone.SSG_Asset_ICBCClaim != null && phone.SSG_Asset_ICBCClaim.IsDuplicated)
            {
                Guid duplicatedPhoneId = await _duplicateDetectService.Exists(phone.SSG_Asset_ICBCClaim, phone);

                if (duplicatedPhoneId != Guid.Empty)
                {
                    return new SSG_SimplePhoneNumber()
                           {
                               SimplePhoneNumberId = duplicatedPhoneId
                           }
                }
                ;
            }
            return(await this._oDataClient.For <SSG_SimplePhoneNumber>().Set(phone).InsertEntryAsync(cancellationToken));
        }
        public async Task with_duplicated_insurance_contains_same_simplePhone_CreateSimplePhoneNumber_should_return_original_involvedparty_guid()
        {
            Guid originalGuid = Guid.NewGuid();

            _duplicateServiceMock.Setup(x => x.Exists(It.Is <SSG_Asset_ICBCClaim>(m => m.ICBCClaimId == _testId), It.Is <SimplePhoneNumberEntity>(m => m.PhoneNumber == "contains")))
            .Returns(Task.FromResult(originalGuid));

            var phone = new SimplePhoneNumberEntity()
            {
                PhoneNumber         = "contains",
                SSG_Asset_ICBCClaim = new SSG_Asset_ICBCClaim()
                {
                    ICBCClaimId  = _testId,
                    IsDuplicated = true
                }
            };
            var result = await _sut.CreateSimplePhoneNumber(phone, CancellationToken.None);

            Assert.AreEqual(originalGuid, result.SimplePhoneNumberId);
        }
        public async Task with_non_duplicated_insurance_CreateSimplePhoneNumber_should_return_new_SSG_InvolvedParty()
        {
            _odataClientMock.Setup(x => x.For <SSG_SimplePhoneNumber>(null).Set(It.Is <SimplePhoneNumberEntity>(x => x.PhoneNumber == "normal"))
                                   .InsertEntryAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_SimplePhoneNumber()
            {
                SimplePhoneNumberId = _testSimplePhoneId
            })
                     );
            var phone = new SimplePhoneNumberEntity()
            {
                PhoneNumber         = "normal",
                SSG_Asset_ICBCClaim = new SSG_Asset_ICBCClaim()
                {
                    IsDuplicated = false
                }
            };
            var result = await _sut.CreateSimplePhoneNumber(phone, CancellationToken.None);

            Assert.AreEqual(_testSimplePhoneId, result.SimplePhoneNumberId);
        }
Пример #6
0
        public async Task insurance_does_not_contain_same_simplePhone_Exists_should_return_empty_guid()
        {
            DuplicateDetectionService._configs = null;
            Guid existedSimplePhoneID     = Guid.NewGuid();
            SSG_Asset_ICBCClaim insurance = new SSG_Asset_ICBCClaim()
            {
                SSG_SimplePhoneNumbers = new List <SSG_SimplePhoneNumber>()
                {
                    new SSG_SimplePhoneNumber()
                    {
                        PhoneNumber = "11111", Extension = "444", SimplePhoneNumberId = existedSimplePhoneID
                    }
                }.ToArray()
            };
            SimplePhoneNumberEntity entity = new SimplePhoneNumberEntity()
            {
                PhoneNumber = "11111", Extension = "333"
            };
            Guid guid = await _sut.Exists(insurance, entity);

            Assert.AreEqual(Guid.Empty, guid);
        }