示例#1
0
        /// <summary>
        /// Gets tax rate
        /// </summary>
        /// <param name="taxRateRequest">Tax rate request</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the ax
        /// </returns>
        public async Task <TaxRateResult> GetTaxRateAsync(TaxRateRequest taxRateRequest)
        {
            if (taxRateRequest.Address == null)
            {
                return new TaxRateResult {
                           Errors = new List <string> {
                               "Address is not set"
                           }
                }
            }
            ;

            //get tax rate
            var taxRate = await _avalaraTaxManager.GetTaxRateAsync(taxRateRequest);

            if (!taxRate.HasValue)
            {
                return new TaxRateResult {
                           Errors = new List <string> {
                               "No response from the service"
                           }
                }
            }
            ;

            return(new TaxRateResult {
                TaxRate = taxRate.Value
            });
        }