public async Task <StringMatcherOutput> MatchStringsAsync(StringMatcherModel matcherModel) { var output = new StringMatcherOutput { Results = new int[matcherModel.Queries.Length] }; await MatchingStringsAsync(matcherModel, output); return(output); }
private async Task MatchingStringsAsync(StringMatcherModel matcherModel, StringMatcherOutput output) { await Task.Run(() => { try { var stringList = matcherModel.Strings; foreach (var query in matcherModel.Queries.Select((value, index) => (value, index))) { var searchResults = stringList.ToList().FindAll(x => x == query.value); output.Results[query.index] = searchResults?.Count ?? 0; } } catch (Exception e) { Console.WriteLine(e); _logger.LogError(e.Message, e); throw; } }); }