public async Task <PagedQuery <ApiResourceDTO> > SearchAsync(SearchDTO search) { var query = from api in Apis .Include(x => x.UserClaims) .Include(o => o.Secrets) .Include(o => o.Scopes) .ThenInclude(s => s.UserClaims) orderby api.Name select api; if (!string.IsNullOrWhiteSpace(search.Search)) { query = from obj in query where obj.Name.Contains(search.Search) orderby obj.Name select obj; } var items = await query.Select(s => s.ToDTO()).ToListAsync(); var result = new PagedQuery <ApiResourceDTO> { Count = search.Count, Items = items, Start = search.Start, Total = items.Count() }; return(result); }
public async Task <ApiResourceDTO> GetAsync(int id) { var query = from api in Apis .Include(x => x.UserClaims) .Include(o => o.Secrets) .Include(o => o.Scopes) .ThenInclude(s => s.UserClaims) where api.Id == id select api; var result = await query.FirstOrDefaultAsync(); return(result.ToDTO()); }