/// <summary>
        /// Uninstall the plugin
        /// </summary>
        /// <returns>A task that represents the asynchronous operation</returns>
        public override async Task UninstallAsync()
        {
            //generic attributes
            await _avalaraTaxManager.DeleteAttributesAsync();

            //settings
            _taxSettings.ActiveTaxProviderSystemName = (await _taxPluginManager.LoadAllPluginsAsync())
                                                       .FirstOrDefault(taxProvider => !taxProvider.PluginDescriptor.SystemName.Equals(AvalaraTaxDefaults.SystemName))
                                                       ?.PluginDescriptor.SystemName;
            await _settingService.SaveSettingAsync(_taxSettings);

            _widgetSettings.ActiveWidgetSystemNames.Remove(AvalaraTaxDefaults.SystemName);
            await _settingService.SaveSettingAsync(_widgetSettings);

            await _settingService.DeleteSettingAsync <AvalaraTaxSettings>();

            //schedule task
            var task = await _scheduleTaskService.GetTaskByTypeAsync(AvalaraTaxDefaults.DownloadTaxRatesTask.Type);

            if (task is not null)
            {
                await _scheduleTaskService.DeleteTaskAsync(task);
            }

            //locales
            await _localizationService.DeleteLocaleResourcesAsync("Enums.Nop.Plugin.Tax.Avalara.Domain");

            await _localizationService.DeleteLocaleResourcesAsync("Plugins.Tax.Avalara");

            await base.UninstallAsync();
        }
Esempio n. 2
0
        /// <summary>
        /// Prepare paged tax provider list model
        /// </summary>
        /// <param name="searchModel">Tax provider search model</param>
        /// <returns>Tax provider list model</returns>
        public virtual async Task <TaxProviderListModel> PrepareTaxProviderListModelAsync(TaxProviderSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get tax providers
            var taxProviders = (await _taxPluginManager.LoadAllPluginsAsync()).ToPagedList(searchModel);

            //prepare grid model
            var model = new TaxProviderListModel().PrepareToGrid(searchModel, taxProviders, () =>
            {
                return(taxProviders.Select(provider =>
                {
                    //fill in model values from the entity
                    var taxProviderModel = provider.ToPluginModel <TaxProviderModel>();

                    //fill in additional values (not existing in the entity)
                    taxProviderModel.ConfigurationUrl = provider.GetConfigurationPageUrl();
                    taxProviderModel.IsPrimaryTaxProvider = _taxPluginManager.IsPluginActive(provider);

                    return taxProviderModel;
                }));
            });

            return(model);
        }
Esempio n. 3
0
        public async Task CanLoadTaxProviders()
        {
            var providers = await _taxPluginManager.LoadAllPluginsAsync();

            providers.Should().NotBeNull();
            providers.Any().Should().BeTrue();
        }