public ActionResult Configure() { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var pxPaymentSettings = _settingService.LoadSetting<PaymentExpressPaymentSettings>(storeScope); var model = new ConfigurationModel(); model.PxUrl = pxPaymentSettings.PxUrl; model.PxUserId = pxPaymentSettings.PxUserId; model.PxPassword = pxPaymentSettings.PxPassword; model.ActiveStoreScopeConfiguration = storeScope; if (storeScope > 0) { model.PxUrl_OverrideForStore = _settingService.SettingExists(pxPaymentSettings, x => x.PxUrl, storeScope); model.PxUserId_OverrideForStore = _settingService.SettingExists(pxPaymentSettings, x => x.PxUserId, storeScope); model.PxPassword_OverrideForStore = _settingService.SettingExists(pxPaymentSettings, x => x.PxPassword, storeScope); } return View("Nop.Plugin.Payments.PaymentExpress.Views.PaymentExpress.Configure", 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 pxPaymentSettings = _settingService.LoadSetting<PaymentExpressPaymentSettings>(storeScope); //save settings pxPaymentSettings.PxUrl = model.PxUrl; pxPaymentSettings.PxUserId = model.PxUserId; pxPaymentSettings.PxPassword = model.PxPassword; /* 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.PxUrl_OverrideForStore || storeScope == 0) _settingService.SaveSetting(pxPaymentSettings, x => x.PxUrl, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(pxPaymentSettings, x => x.PxUrl, storeScope); if (model.PxUserId_OverrideForStore || storeScope == 0) _settingService.SaveSetting(pxPaymentSettings, x => x.PxUserId, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(pxPaymentSettings, x => x.PxUserId, storeScope); if (model.PxPassword_OverrideForStore || storeScope == 0) _settingService.SaveSetting(pxPaymentSettings, x => x.PxPassword, storeScope, false); else if (storeScope > 0) _settingService.DeleteSetting(pxPaymentSettings, x => x.PxPassword, storeScope); //now clear settings cache _settingService.ClearCache(); return Configure(); }