Example #1
0
        private static void UpsertPrdNexus(AvaTaxClient prdClient, List <NexusModel> nexus)
        {
            //Get existing PRD nexus.
            var prdNexus = prdClient.ListNexusByCompany(PRD_COMPANY_ID, "nexusTaxTypeGroup EQ LandedCost", string.Empty, null, null, string.Empty).value;

            //Change the company ID to PRD.
            foreach (NexusModel indNexus in nexus)
            {
                //Check if the nexus already exists in the company.
                if (prdNexus.Select(pn => pn.country == indNexus.country).Any())
                {
                    continue;
                }

                try
                {
                    indNexus.companyId = PRD_COMPANY_ID;
                    var nexusToAdd = new List <NexusModel> {
                        indNexus
                    };
                    prdClient.CreateNexus(PRD_COMPANY_ID, nexusToAdd);
                }
                catch (AvaTaxError exc)
                {
                    Console.WriteLine(string.Format("Error in adding nexus", exc.Message, exc.InnerException));
                    Console.WriteLine(string.Format("More information: {0}", exc.error));
                    continue;
                }
                catch (Exception exc)
                {
                    Console.WriteLine(string.Format("Other error occurred in loading nexus: {0}", exc.Message));
                }
            }
        }
Example #2
0
 private static void ExtractSbxNexus(AvaTaxClient sbxClient, List <NexusModel> nexus)
 {
     nexus.AddRange(sbxClient.ListNexusByCompany(SBX_COMPANY_ID, "nexusTaxTypeGroup EQ LandedCost", string.Empty, null, null, string.Empty).value);
 }