public IActionResult List(string repository = null, string branch = null, int?channelId = null, bool?enabled = null) { IQueryable <Data.Models.DefaultChannel> query = _context.DefaultChannels.Include(dc => dc.Channel) .AsNoTracking(); if (!string.IsNullOrEmpty(repository)) { query = query.Where(dc => dc.Repository == repository); } if (!string.IsNullOrEmpty(branch)) { // Normalize the branch name to not include refs/heads string normalizedBranchName = IGitRepoExtension.NormalizeBranchName(branch); query = query.Where(dc => dc.Branch == normalizedBranchName); } if (channelId.HasValue) { query = query.Where(dc => dc.ChannelId == channelId.Value); } if (enabled.HasValue) { query = query.Where(dc => dc.Enabled == enabled.Value); } List <DefaultChannel> results = query.AsEnumerable().Select(dc => new DefaultChannel(dc)).ToList(); return(Ok(results)); }
public IActionResult ListRepositories(string repository = null, string branch = null) { IQueryable <Data.Models.RepositoryBranch> query = Context.RepositoryBranches; if (!string.IsNullOrEmpty(repository)) { query = query.Where(r => r.RepositoryName == repository); } if (!string.IsNullOrEmpty(branch)) { string normalizedBranchName = IGitRepoExtension.NormalizeBranchName(branch); query = query.Where(r => r.BranchName == normalizedBranchName); } return(Ok(query.AsEnumerable().Select(r => new RepositoryBranch(r)).ToList())); }