public async Task UpdateAsync() { var ids = await indexForApps.GetIdsAsync(); foreach (var id in ids) { var app = await indexForApps.GetAppAsync(id); if (app != null && app.Patterns.Count == 0) { foreach (var pattern in initialPatterns.Values) { var command = new AddPattern { Actor = app.CreatedBy, AppId = id, Name = pattern.Name, PatternId = Guid.NewGuid(), Pattern = pattern.Pattern, Message = pattern.Message }; await commandBus.PublishAsync(command); } } } }