public ActionResult Configure() { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var vkCommunitySettings = _settingService.LoadSetting<VkCommunitySettings>(storeScope); var model = new ConfigurationModel(); model.VkCode = vkCommunitySettings.VkCode; model.ActiveStoreScopeConfiguration = storeScope; if (storeScope > 0) { model.VkCode_OverrideForStore = _settingService.SettingExists(vkCommunitySettings, x => x.VkCode, storeScope); } return View("~/Plugins/Widgets.VkCommunity/Views/WidgetsVkCommunity/Configure.cshtml", model); }
public ActionResult Configure(ConfigurationModel model) { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var vkCommunitySettings = _settingService.LoadSetting<VkCommunitySettings>(storeScope); vkCommunitySettings.VkCode = model.VkCode; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.VkCode_OverrideForStore || storeScope == 0) _settingService.SaveSetting(vkCommunitySettings, x => x.VkCode, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(vkCommunitySettings, x => x.VkCode, storeScope); //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return Configure(); }