public async Task <IEnumerable <ModuleListModel> > HandleAsync(ModuleSearchQuery query, [FromServices][Inject] IModuleSearchEngine searchEngine) { var modules = await searchEngine.SearchModulesAsync(query.SearchPhrase, query.IncludePreReleases, cancellation : default); var projection = new ModuleProjection(); return(modules.Select(p => projection.ProjectToListModel(p, query.IncludePreReleases)).ToList()); }
public async Task <IActionResult> Index(ModulesSearchModel model) { var query = new ModuleSearchQuery(model.SearchPhrase, model.IncludePreReleases); var queryResult = await _messageDispatcher.DispatchAsync(query); if (queryResult.IsSuccessWithResult <IEnumerable <ModuleListModel> >(out var searchResult)) { model.SearchResult = new List <ModuleListModel>(searchResult); return(View(model)); } return(GetActionResult(queryResult)); }