public async Task<TableStorageResponse<UserSetting>> SetUserSettingValueAsync(UserSetting setting)
        {
            var incomingEntity =
                new UserSettingTableEntity()
                {
                    PartitionKey = _settingsTablePartitionKey,
                    RowKey = setting.Key,
                    SettingValue = setting.Value
                };

            if (!string.IsNullOrWhiteSpace(setting.Etag))
            {
                incomingEntity.ETag = setting.Etag;
            }

            TableStorageResponse<UserSetting> result = await AzureTableStorageHelper.DoTableInsertOrReplaceAsync<UserSetting, UserSettingTableEntity>(incomingEntity, (tableEntity) =>
                {
                    if (tableEntity == null)
                    {
                        return null;
                    }

                    var updatedSetting = new UserSetting()
                    {
                        Key = tableEntity.RowKey,
                        Value = tableEntity.SettingValue,
                        Etag = tableEntity.ETag
                    };

                    return updatedSetting;
                }, _storageAccountConnectionString, _settingsTableName);

            return result;
        }
Exemple #2
0
 public UserSetting(UserSettingTableEntity entity)
 {
     Key   = entity.RowKey;
     Value = entity.SettingValue;
     Etag  = entity.ETag;
 }