public void DeleteSetting(SettingStore store, SettingModel setting) { var currentSettings = GetSettingsFromStore(store); using (TransactionScope scope = TransactionScopeFactory.CreateReaduncommited()) { if (setting == null || string.IsNullOrWhiteSpace(setting.Key)) { throw new SettingsStoreException(Constants.ERROR_SETTING_NO_KEY); } var existing = currentSettings.SingleOrDefault(s => s.Equals(setting)); if (existing != null) { if (Auth.AllowDeleteSetting(store.ApplicationName, store.DirectoryName)) { Store.Context.Settings.Remove(existing); } else { throw new SettingsAuthorizationException(AuthorizationScope.Setting, AuthorizationLevel.Write, store.DirectoryName, Auth.CurrentIdentity.Id); } } else { throw new SettingsNotFoundException(setting.Key); } Store.Save(); scope.Complete(); } }
public IHttpActionResult SaveSetting(SettingStore store, SettingModel value) { try { controller.SaveSetting(store, value); return Ok(); } catch (Exception ex) { return Error(ex); } }
public void SaveSetting(SettingStore store, SettingModel setting) { SaveSettings(store, new[] { setting }); }