public override IQueryable <User> Filter(IQueryable <User> entities, FilterQuery filterQuery) { if (filterQuery.Attribute.Equals("name", StringComparison.OrdinalIgnoreCase)) { return(entities.Where(u => EFUtils.Like(u.Name, filterQuery.Value))); } return(entities.OptionallyFilterOnQueryParam(filterQuery, "organization-id", this, CurrentUserContext, GetWithOrganizationId, FilterOnOrganizationHeader, null, null)); }
public override IQueryable <Project> Filter(IQueryable <Project> entities, FilterQuery filterQuery) { if (filterQuery.Has(ORGANIZATION_HEADER)) { var orgIds = CurrentUser.OrganizationIds.OrEmpty(); return(entities.FilterByOrganization(filterQuery, allowedOrganizationIds: orgIds)); } var value = filterQuery.Value; var op = filterQuery.Operation.ToEnum <FilterOperations>(defaultValue: FilterOperations.eq); if (filterQuery.Has(PROJECT_UPDATED_DATE)) { var date = value.DateTimeFromISO8601(); switch (op) { case FilterOperations.ge: return(entities .Where(p => p.DateUpdated > date)); case FilterOperations.le: return(entities .Where(p => p.DateUpdated < date)); } } if (filterQuery.Has(PROJECT_PRODUCT_NAME_ANY)) { return(entities .Include(p => p.Products) .ThenInclude(product => product.ProductDefinition) .Where(p => p.Products .Any(product => EFUtils.Like(product.ProductDefinition.Name, value)))); } if (filterQuery.Has(PROJECT_PRODUCT_DEFINITION_ID_ANY)) { return(entities .Include(p => p.Products) .Where(p => p.Products .Any(product => product.ProductDefinitionId.ToString() == value))); } if (filterQuery.Has(PROJECT_SEARCH_TERM)) { return(entities .Include(p => p.Owner) .Include(p => p.Organization) .Include(p => p.Group) .Where(p => ( EFUtils.Like(p.Name, value) || EFUtils.Like(p.Language, value) || EFUtils.Like(p.Organization.Name, value) || EFUtils.Like(p.Owner.Name, value) || EFUtils.Like(p.Group.Name, value) ))); } return(base.Filter(entities, filterQuery)); }