public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) return Configure(); var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var yandexKassaPaymentSettings = _settingService.LoadSetting<YandexKassaPaymentSettings>(storeScope); yandexKassaPaymentSettings.UseSandbox = model.UseSandbox; yandexKassaPaymentSettings.BusinessEmail = model.BusinessEmail; yandexKassaPaymentSettings.ShopId = Convert.ToInt32(model.ShopId); yandexKassaPaymentSettings.Scid = Convert.ToInt32(model.Scid); ///* 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.UseSandbox_OverrideForStore || storeScope == 0) _settingService.SaveSetting(yandexKassaPaymentSettings, x => x.UseSandbox, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(yandexKassaPaymentSettings, x => x.UseSandbox, storeScope); if (model.BusinessEmail_OverrideForStore || storeScope == 0) _settingService.SaveSetting(yandexKassaPaymentSettings, x => x.BusinessEmail, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(yandexKassaPaymentSettings, x => x.BusinessEmail, storeScope); if (model.ShopId_OverrideForStore || storeScope == 0) _settingService.SaveSetting(yandexKassaPaymentSettings, x => x.ShopId, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(yandexKassaPaymentSettings, x => x.ShopId, storeScope); if (model.Scid_OverrideForStore || storeScope == 0) _settingService.SaveSetting(yandexKassaPaymentSettings, x => x.Scid, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(yandexKassaPaymentSettings, x => x.Scid, storeScope); // now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return Configure(); }
public ActionResult Configure() { var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var yandexKassaPaymentSettings = _settingService.LoadSetting<YandexKassaPaymentSettings>(storeScope); var model = new ConfigurationModel(); model.UseSandbox = Convert.ToBoolean(yandexKassaPaymentSettings.UseSandbox); model.BusinessEmail = yandexKassaPaymentSettings.BusinessEmail; model.ShopId = Convert.ToString(yandexKassaPaymentSettings.ShopId); model.Scid = Convert.ToString(yandexKassaPaymentSettings.Scid); model.ActiveStoreScopeConfiguration = storeScope; if (storeScope > 0) { model.UseSandbox_OverrideForStore = _settingService.SettingExists(yandexKassaPaymentSettings, x => x.UseSandbox, storeScope); model.BusinessEmail_OverrideForStore = _settingService.SettingExists(yandexKassaPaymentSettings, x => x.BusinessEmail, storeScope); model.ShopId_OverrideForStore = _settingService.SettingExists(yandexKassaPaymentSettings, x => x.ShopId, storeScope); model.Scid_OverrideForStore = _settingService.SettingExists(yandexKassaPaymentSettings, x => x.Scid, storeScope); } return View("~/Plugins/Payments.YandexKassa/Views/PaymentYandexKassa/Configure.cshtml", model); }