private static async Task <bool> EnsureTableExists(IAmazonDynamoDB client, IDynamoTable table) { if (table == null || client == null) { return(false); } var createRequest = table.CreateRequest; var created = await client.CreateTableAsync(createRequest).ConfigureAwait(true); return(created?.HttpStatusCode == System.Net.HttpStatusCode.OK); }
/// <summary> /// Creates the Recipes table, if it does not already exist. /// </summary> /// <returns>True if there's a good table to use, false otherwise.</returns> public static bool EnsureTablesExists(IAmazonDynamoDB client) { if (Initialized) { return(true); } if (client == null) { return(false); } lock (LockObject) { if (!Initialized) { var creates = new List <Task <bool> >(); var tables = new IDynamoTable[] { new Recipe(), new Meal(), new Person(), new Plan() }; var request = new ListTablesRequest { Limit = 10 }; var response = client.ListTablesAsync(request).GetAwaiter().GetResult(); foreach (var table in tables) { if (!response.TableNames.Contains(table.TableName)) { creates.Add(EnsureTableExists(client, table)); } } Task.WaitAll(creates.ToArray()); var success = creates.TrueForAll(s => s.Result); Initialized = true; return(success); } } return(true); }
private RoomStore(IDynamoTable dynamoTable, IRandomRoomCode randomRoomCode) { _dynamoTable = dynamoTable ?? new DynamoTable(); _randomRoomCode = randomRoomCode ?? new RandomRoomCode(); }
// TODO: Move this to some dependency manager public static IRoomStore Create(IDynamoTable dynamoTable = null, IRandomRoomCode randomRoomCode = null) { return(new RoomStore(dynamoTable, randomRoomCode)); }
public void SetTable(string key, IDynamoTable table) { // Replace the existing table, if exists. tables[key] = table; }
public BaseDynamoRepository(IDynamoTable dynamoTable) { this.dynamoTable = dynamoTable; }