public async Task <T> GetSettings <T>(string traderId) where T : TraderSettingsBase, new() { var partitionKey = ClientSettingsEntity.GeneratePartitionKey(traderId); var defaultValue = TraderSettingsBase.CreateDefault <T>(); var rowKey = ClientSettingsEntity.GenerateRowKey(defaultValue); var entity = await _tableStorage.GetDataAsync(partitionKey, rowKey); return(entity == null ? defaultValue : entity.GetSettings <T>()); }
public static ClientSettingsEntity Create(string traderId, TraderSettingsBase settings) { var result = new ClientSettingsEntity { PartitionKey = GeneratePartitionKey(traderId), RowKey = GenerateRowKey(settings), }; result.SetSettings(settings); return(result); }
public Task SetSettings <T>(string traderId, T settings) where T : TraderSettingsBase, new() { var newEntity = ClientSettingsEntity.Create(traderId, settings); return(_tableStorage.InsertOrReplaceAsync(newEntity)); }