public Task SetAsync(SettingKey settingKey, string value, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(value)); return PostAsync( $"/api/settings/{settingKey.Value}", value, cancellationToken); }
public async Task<string> GetAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, CancellationToken cancellationToken) { var values = await _msSqlConnection.QueryAsync<string>( cancellationToken, GetSql, new {Key = settingKey.Value, GroupKey = settingGroupKey.Value }) .ConfigureAwait(false); return values.SingleOrDefault(); }
public async Task SetAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, string value, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(value)); var affectedRows = await _msSqlConnection.ExecuteAsync( cancellationToken, SetSql, new {Key = settingKey.Value, Value = value, GroupKey = settingGroupKey.Value}) .ConfigureAwait(false); if (affectedRows != 1) { throw new Exception($"Updating key '{settingKey}' didn't update any rows"); } }
public Task<string> GetAsync(SettingKey settingKey, CancellationToken cancellationToken) { return GetAsync( $"/api/settings/{settingKey.Value}", cancellationToken); }
public Task RemoveAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, CancellationToken cancellationToken) { return _msSqlConnection.ExecuteAsync( cancellationToken, DeleteSql, new {Key = settingKey.Value, GroupKey = settingGroupKey.Value }); }