Beispiel #1
0
        private void SynchronizeAddresses(CustomerEntity customer, PsCustomer psCustomer)
        {
            var address = customer.GetMainAddress();

            if (address != null && address.IsValid)
            {
                var psAddress = GetPsAddress(address.WebId);

                if (psAddress == null && address.WebId.HasValue)
                {
                    address.WebId = null;
                }

                if (psAddress == null)
                {
                    if (!address.IsArchived)
                    {
                        psAddress = InsertAddress(psCustomer, address, "Domyślny");
                    }
                }
                else
                {
                    if (address.IsArchived)
                    {
                        DeleteAddress(address, psAddress);
                    }
                    else
                    {
                        UpdateAddress(address, psAddress);
                    }
                }

                if (psAddress != null)
                {
                    psAddress = SaveOrUpdateAddress(address, psAddress);
                }

                if (!address.WebId.HasValue)
                {
                    address.WebId = (int?)psAddress?.id;
                }

                address.Synchronize = Framework.SynchronizeType.Synchronized;
            }
        }