public static void SetCustomerPrimaryAddress(int customerID, AddressType type) { if (type == AddressType.Main || type == AddressType.New) { return; } var addressesOnFile = Exigo.GetCustomerAddresses(customerID) .Where(c => c.IsComplete); var oldPrimaryAddress = addressesOnFile .Where(c => c.AddressType == AddressType.Main) .FirstOrDefault(); var newPrimaryAddress = addressesOnFile .Where(c => c.AddressType == type) .FirstOrDefault(); if (oldPrimaryAddress == null || newPrimaryAddress == null) { return; } // Swap the addresses Exigo.SetCustomerAddressOnFile(customerID, (Address)newPrimaryAddress, AddressType.Main); Exigo.SetCustomerAddressOnFile(customerID, (Address)oldPrimaryAddress, type); }