private static async Task <CurrentPageIndexTableEntity> Create(CloudTable table, CancellationToken token) { var entity = new CurrentPageIndexTableEntity { PartitionKey = "Indexes", RowKey = "CurrentPageIndex", Index = 0 }; var operation = TableOperation.Insert(entity); try { var result = await table.ExecuteAsync(operation, token); return((CurrentPageIndexTableEntity)result.Result); } catch (StorageException e) { if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.Conflict) { throw; } return(null); } }
public async Task TryUpdate(CurrentPageIndexTableEntity entity, CancellationToken token) { var table = await _table.GetOrCreate(); var operation = TableOperation.Replace(entity); try { await table.ExecuteAsync(operation, token); } catch (StorageException e) { if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.PreconditionFailed) { throw; } } }