Exemplo n.º 1
0
        public ResultsObject DoAddressUpdate(Address address, ResultsObject ro, CONTACT1ChangeTracking_Result ctResult)
        {
            string dataapi_addressId = _apiClient.GetExistingAddress(address.first_line, address.postcode);

            if (!string.IsNullOrEmpty(dataapi_addressId))
            {
                bool fullAddressUpdate = AddressHelper.CheckForFullAddressUpdate(ctResult);
                if (!fullAddressUpdate)
                {
                    bool othersLinkedToThisAddress = _apiClient.CheckForOthersLinkedToThisAddress(dataapi_addressId);
                    if (othersLinkedToThisAddress)
                    {
                        string personId          = _apiClient.GetPersonId(ro.ReferenceNumber);
                        bool   imLinkedToAddress = _apiClient.CheckIfImLinkedToAddress(dataapi_addressId, personId);
                        if (!imLinkedToAddress)
                        {
                            CreateAddress(address, ro);
                        }
                    }
                    else
                    {
                        _apiClient.AmendCurrentAddress(address, ro, dataapi_addressId);
                    }
                }
                else
                {
                    string personId          = _apiClient.GetPersonId(ro.ReferenceNumber);
                    bool   imLinkedToAddress = _apiClient.CheckIfImLinkedToAddress(dataapi_addressId, personId);
                    if (!imLinkedToAddress)
                    {
                        CreateAddress(address, ro);
                    }
                }
            }
            else
            {
                CreateAddress(address, ro);
            }
FINISH:
            return(ro);
        }
        private bool ReferenceNumberExists(string referenceNumber)
        {
            string personId = _dataAPIClient.GetPersonId(referenceNumber);

            if (string.IsNullOrEmpty(personId))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }