Ejemplo n.º 1
0
        public override IQueryable <OrganizationStore> Filter(IQueryable <OrganizationStore> entities, FilterQuery filterQuery)
        {
            if (filterQuery.Has(ORGANIZATION_HEADER))
            {
                var orgIds = CurrentUser.OrganizationIds.OrEmpty();

                return(entities.FilterByOrganization(filterQuery, allowedOrganizationIds: orgIds));
            }


            return(base.Filter(entities, filterQuery));
        }
        public override IQueryable <UserTask> Filter(IQueryable <UserTask> query, FilterQuery filterQuery)
        {
            var all = query.ToList();

            if (filterQuery.Has(ORGANIZATION_HEADER))
            {
                var orgIds = CurrentUser.OrganizationIds.OrEmpty();

                return(this.FilterByOrganization(query, filterQuery, allowedOrganizationIds: orgIds));
            }

            return(base.Filter(query, filterQuery));
        }
Ejemplo n.º 3
0
        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));
        }