public virtual IActionResult ProviderUpdate(ShippingProviderModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } var srcm = _shippingService.LoadShippingRateComputationMethodBySystemName(model.SystemName); if (_shippingService.IsShippingRateComputationMethodActive(srcm)) { if (!model.IsActive) { //mark as disabled _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Remove(srcm.PluginDescriptor.SystemName); _settingService.SaveSetting(_shippingSettings); } } else { if (model.IsActive) { //mark as active _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add(srcm.PluginDescriptor.SystemName); _settingService.SaveSetting(_shippingSettings); } } var pluginDescriptor = srcm.PluginDescriptor; //display order pluginDescriptor.DisplayOrder = model.DisplayOrder; //update the description file PluginManager.SavePluginDescriptor(pluginDescriptor); //reset plugin cache _pluginFinder.ReloadPlugins(pluginDescriptor); return(new NullJsonResult()); }
public virtual async Task <IActionResult> ProviderUpdate(ShippingProviderModel model) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } var srcm = await _shippingPluginManager.LoadPluginBySystemNameAsync(model.SystemName); if (_shippingPluginManager.IsPluginActive(srcm)) { if (!model.IsActive) { //mark as disabled _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Remove(srcm.PluginDescriptor.SystemName); await _settingService.SaveSettingAsync(_shippingSettings); } } else { if (model.IsActive) { //mark as active _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add(srcm.PluginDescriptor.SystemName); await _settingService.SaveSettingAsync(_shippingSettings); } } var pluginDescriptor = srcm.PluginDescriptor; //display order pluginDescriptor.DisplayOrder = model.DisplayOrder; //update the description file pluginDescriptor.Save(); //raise event await _eventPublisher.PublishAsync(new PluginUpdatedEvent(pluginDescriptor)); return(new NullJsonResult()); }