public ActionResult Configure() { //load widgets from xml ViewBag.Zones = GetWidgetZones(); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var setting = _settingService.LoadSetting<ENamadSettings>(storeScope); var model = new ConfigurationModel { PlacedIn = setting.PlacedIn, IsActive = setting.IsActive, ENamadCode = setting.ENamadCode, ActiveStoreScopeConfiguration = storeScope }; if (storeScope > 0) { model.PlacedIn_OverrideForStore = _settingService.SettingExists(setting, x => x.PlacedIn, storeScope); model.IsActive_OverrideForStore = _settingService.SettingExists(setting, x => x.IsActive, storeScope); model.ENamadCode_OverrideForStore = _settingService.SettingExists(setting, x => x.ENamadCode, storeScope); } return View("~/Plugins/Widgets.ENamad/Views/WidgetsENamad/Configure.cshtml", model); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) return Configure(); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var setting = _settingService.LoadSetting<ENamadSettings>(storeScope); setting.PlacedIn = model.PlacedIn; setting.IsActive = model.IsActive; setting.ENamadCode = model.ENamadCode; if (model.PlacedIn_OverrideForStore || storeScope == 0) _settingService.SaveSetting(setting, x => x.PlacedIn, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(setting, x => x.PlacedIn, storeScope); if (model.IsActive_OverrideForStore || storeScope == 0) _settingService.SaveSetting(setting, x => x.IsActive, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(setting, x => x.IsActive, storeScope); if (model.ENamadCode_OverrideForStore || storeScope == 0) _settingService.SaveSetting(setting, x => x.ENamadCode, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(setting, x => x.ENamadCode, storeScope); //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); ViewBag.Zones = GetWidgetZones(model.PlacedIn); return Configure(); }