public static async Task <int> GetNextId(CloudTable interventionsTable) { InterventionCountEntity counter = await GetCountEntity(interventionsTable); (int nextCount, TableOperation operation) = GetNextCount(counter); await interventionsTable.ExecuteAsync(operation); return(nextCount); }
private static (int, TableOperation) GetNextCount(InterventionCountEntity counter) { if (counter == null) { var newCounter = new InterventionCountEntity(); return(newCounter.Count, TableOperation.Insert(newCounter)); } else { return(++counter.Count, TableOperation.Replace(counter)); } }