示例#1
0
        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);
        }
示例#2
0
        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();
        }
示例#3
0
        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");
            }
        }
示例#4
0
 public Task<string> GetAsync(SettingKey settingKey, CancellationToken cancellationToken)
 {
     return GetAsync(
         $"/api/settings/{settingKey.Value}",
         cancellationToken);
 }
示例#5
0
 public Task RemoveAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, CancellationToken cancellationToken)
 {
     return _msSqlConnection.ExecuteAsync(
         cancellationToken,
         DeleteSql,
         new {Key = settingKey.Value, GroupKey = settingGroupKey.Value });
 }