コード例 #1
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public async Task <IActionResult> ExportTaxCodes()
        {
            //ensure that Avalara tax provider is active
            if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName))
            {
                return(await Categories());
            }

            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings))
            {
                return(AccessDeniedView());
            }

            //export tax codes
            var exportedTaxCodes = await _avalaraTaxManager.ExportTaxCodesAsync();

            if (exportedTaxCodes.HasValue)
            {
                if (exportedTaxCodes > 0)
                {
                    _notificationService.SuccessNotification(string.Format(await _localizationService.GetResourceAsync("Plugins.Tax.Avalara.TaxCodes.Export.Success"), exportedTaxCodes));
                }
                else
                {
                    _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Plugins.Tax.Avalara.TaxCodes.Export.AlreadyExported"));
                }
            }
            else
            {
                _notificationService.ErrorNotification(await _localizationService.GetResourceAsync("Plugins.Tax.Avalara.TaxCodes.Export.Error"));
            }

            return(await Categories());
        }