private async Task AssignBranchesToProjects(FilteredResutsDto <ProjectDto> projects) { foreach (var project in projects.Results) { await AssignBranchesToProject(project); } }
public async Task <FilteredResutsDto <ProjectDto> > GetProjectsAsync(ProjectsFilterDto filter, string userId) { IList <ProjectDto> projects = null; if (!_cacheService.TryGetProjects(out projects)) { var projectsTask = _projectsClient.Get(); var usersTask = _usersClient.Get(); projects = await projectsTask; CleanProjectsAccessTokens(projects); var users = await usersTask; AddOwnersToProjects(projects, users); _cacheService.AddProjectsToCache(projects); } IEnumerable <ProjectDto> query = projects; query = FilterByName(filter, query); query = FilterByDescription(filter, query); query = FilterByGroups(filter, query); query = FilterByTags(filter, query); query = FilterByLimitedAccess(filter, query, userId); var allResults = query.Count(); query = query.OrderBy(x => x.Name); if (filter.Limit > 0) { query = query.Skip(filter.Page * filter.Limit).Take(filter.Limit); } var filteredResults = new FilteredResutsDto <ProjectDto> { Results = query, AllResults = allResults }; return(filteredResults); }