/// <summary> /// Adds all LandedCost nexus to a company. /// </summary> /// <param name="URI">The URI.</param> /// <param name="USER">The user.</param> /// <param name="COMPANY_ID">The company identifier.</param> /// <param name="PASS">The pass.</param> private static void AddLcNexusToCompany(string URI, string USER, int COMPANY_ID, string PASS) { var client = new AvaTaxClient("lcNexusApp", ".1", "AvalaraAddLcNexusApp", new Uri(URI)) .WithSecurity(USER, PASS); var countriesAlreadyAssigned = client.ListNexusByCompany(COMPANY_ID, "nexusTaxTypeGroup EQ 'LandedCost'", "", null, null, "").value; var countries = client.ListNexusByCountry("", "nexusTaxTypeGroup EQ 'LandedCost'", null, null, "").value; List <NexusModel> countriesToAdd = new List <NexusModel>(); foreach (var country in countries) { if (countriesAlreadyAssigned.Any(cas => cas.country == country.country)) { continue; } countriesToAdd.Add(country); } client.CreateNexus(COMPANY_ID, countriesToAdd); Console.WriteLine(string.Format("Added {0} LandedCostNexus to company {1}.", countriesToAdd.Count, COMPANY_ID)); }