public ActionResult Settings(ConfigurationModel configurationModel) { //load settings for a chosen store scope var storeScope = _storeContext.ActiveStoreScopeConfiguration; var settings = configurationModel.ToEntity(); /* 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 (configurationModel.EnableApi_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(settings, x => x.EnableApi, storeScope, false); } if (configurationModel.AllowRequestsFromSwagger_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(settings, x => x.AllowRequestsFromSwagger, storeScope, false); } //now clear settings cache _settingService.ClearCache(); _customerActivityService.InsertActivity("EditApiSettings", "Edit Api Settings"); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(View(ViewNames.AdminApiSettings, configurationModel)); }
public async Task <IActionResult> Settings(ConfigurationModel model) { //load settings for a chosen store scope var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync(); var settings = model.ToEntity(); /* 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.EnableApi_OverrideForStore || storeScope == 0) { await _settingService.SaveSettingAsync(settings, x => x.EnableApi, storeScope, false); } //now clear settings cache await _settingService.ClearCacheAsync(); await _customerActivityService.InsertActivityAsync("EditApiSettings", "Edit Api Settings"); _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Plugins.Saved")); return(View($"~/Plugins/Nop.Plugin.Api/Areas/Admin/Views/ApiAdmin/Settings.cshtml", model)); }
public IActionResult Create(ConfigurationModel model) { Configuration configuration = model.ToEntity(); _configurationService.InsertConfiguration(configuration); if (model.IsActive) { var message = new ServiceMessageModel() { Key = model.ApplicationName, Value = model.Value }; Publisher publisher = new Publisher(message.Key, message.Value); } return(RedirectToAction("Index", "Configuration")); }
public IActionResult Update(string InternalId, ConfigurationModel model) { model.InternalId = new ObjectId(InternalId); Configuration configuration = model.ToEntity(); _configurationService.UpdateConfiguration(configuration); if (model.IsActive) { var message = new ServiceMessageModel() { Key = model.ApplicationName, Value = model.Value }; Publisher publisher = new Publisher(message.Key, message.Value); } return(RedirectToAction("Index", "Configuration")); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeId = _storeContext.ActiveStoreScopeConfiguration; var settings = _settingService.LoadSetting <BarionSettings>(storeId); //save settings settings = model.ToEntity <BarionSettings>(); _settingService.SaveSettingOverridablePerStore(settings, x => x.AdditionalFee, model.AdditionalFee_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.AdditionalFeePercentage, model.AdditionalFeePercentage_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.ApiUrl, model.ApiUrl_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.BarionPayee, model.BarionPayee_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.CallbackUrl, model.CallbackUrl_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.IsSandbox, model.IsSandbox_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.LogPaymentProcess, model.LogPaymentProcess_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.LogTransaction, model.LogTransaction_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.POSKey, model.POSKey_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.RedirectUrl, model.RedirectUrl_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.UseReservationPaymentType, model.UseReservationPaymentType_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.ReservationPeriod, model.ReservationPeriod_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.MarkOrderCompletedAfterPaid, model.MarkOrderCompletedAfterPaid_OverrideForStore, storeId, false); _settingService.ClearCache(); //display notification _notificationService.SuccessNotification(_localizationService.GetResource("Barion.Admin.Plugins.Saved")); return(Configure()); }