public async Task FillDatabase(IEnumerable <CommandInfo> commandInfosFromAssembly) { var commandInfosFromAssemblyList = commandInfosFromAssembly.ToList(); // for not multiple enumerating var query = new GetHelpInformationQuery(HelpInformation.EMPTY_SERVER_ID); var helpInfos = this._queryBus.Execute(query).HelpInformations.ToList(); var newCommands = this.FindNewCommands(commandInfosFromAssemblyList, helpInfos).ToList(); await Task.Run(() => this.CheckIfExistsUselessHelp(commandInfosFromAssemblyList, helpInfos)); var newHelpInfos = newCommands.Select(x => this._helpInformationFactory.Create(x)); var command = new AddHelpInformationCommand(newHelpInfos); await this._commandBus.ExecuteAsync(command); }
public Task FillDatabase(IEnumerable <CommandInfo> commandInfosFromAssembly) { var commandInfosFromAssemblyList = commandInfosFromAssembly.ToList(); var query = new GetHelpInformationQuery(HelpInformation.EMPTY_SERVER_ID); var helpInfos = this._queryBus.Execute(query).HelpInformations.ToList(); this.CheckIfExistsUselessHelp(commandInfosFromAssemblyList, helpInfos); var newCommands = this.FindNewCommands(commandInfosFromAssemblyList, helpInfos).ToList(); if (!newCommands.Any()) { return(Task.CompletedTask); } var newHelpInfos = newCommands.Select(x => this._helpInformationFactory.Create(x)); var command = new AddHelpInformationCommand(newHelpInfos); return(this._commandBus.ExecuteAsync(command)); }