private IEnumerable <TableEntityAdapter <AllGroupsGroupEntry> > ToGroupEntries(IEnumerable <Group> groups) { return(groups.Select(x => { var entry = new AllGroupsGroupEntry { Name = x.Name, Count = x.Count, CreationTime = x.CreationTime.UtcDateTime }; return new TableEntityAdapter <AllGroupsGroupEntry>(entry, PartitionNames.Group, x.Id.ToString("N")); })); }
private async Task AddOrUpdateToGroupsList(GroupMetadata group, Guid groupId, int count) { var allGroupsTable = _tableClient.GetTableReference(TableNames.AllGroups); await allGroupsTable.CreateIfNotExistsAsync(); var groupEntry = new AllGroupsGroupEntry { Name = group.Name, Count = count, CreationTime = group.CreationTime }; var addOrUpdateOperation = TableOperation.InsertOrReplace( new TableEntityAdapter <AllGroupsGroupEntry>(groupEntry, PartitionNames.Group, groupId.ToIdString())); TableResult result = await allGroupsTable.ExecuteAsync(addOrUpdateOperation); if (!(result.Result is TableEntityAdapter <AllGroupsGroupEntry>)) { // This isn't fatal. We'll catch it next time we do a group update. _logger.LogWarning($"Failed to update group list metadata table with new group: ID - {groupId}, Name - {group.Name}. Status code: {result.HttpStatusCode}"); } }