private async Task <BuildsBinding[]> MapToBuildBindings(BuildBindingModel[] bindingModels) { var result = new List <BuildsBinding>(); foreach (BuildBindingModel bindingModel in bindingModels) { BuildMatchPatternReadModel patternReadModel = await buildMatchPatternRepository.Query(x => x.Id == bindingModel.PatternId); var pattern = mapper.Map <BuildMatchPattern>(patternReadModel); result.Add(new BuildsBinding(bindingModel.Path, pattern, bindingModel.SourceType)); } return(result.ToArray()); }
/// <summary> /// Создает экземпляр <see cref="List{SearchBuildsRequestModel}"/>. /// </summary> /// <param name="response">Ответ на запрос на сканирование билдов.</param> /// <param name="patterns">Список билдов.</param> /// <returns>Список результатов сканирования.</returns> public static List <SearchBuildsResultModel> Create(ScanForBuildsListResponse response, IList <BuildMatchPatternReadModel> patterns) { return(response .Items .Select(s => { BuildMatchPatternReadModel pattern = patterns.FirstOrDefault(x => x?.Regexp?.Equals(s.PatternMatch, StringComparison.OrdinalIgnoreCase) ?? false); return new SearchBuildsResultModel { BuildsCount = s.BuildsCount, PatternMatchId = pattern?.Id.ToString() }; }) .ToList()); }