Example #1
0
        protected List <long> FilterOrganization(List <Organization> Organizations, IdFilter IdFilter)
        {
            List <long> In    = null;
            List <long> NotIn = null;

            if (IdFilter.Equal != null)
            {
                if (In == null)
                {
                    In = new List <long>();
                }
                In.Add(IdFilter.Equal.Value);
            }
            if (IdFilter.In != null)
            {
                if (In == null)
                {
                    In = new List <long>();
                }
                In.AddRange(IdFilter.In);
            }

            if (IdFilter.NotEqual != null)
            {
                if (NotIn == null)
                {
                    NotIn = new List <long>();
                }
                NotIn.Add(IdFilter.NotEqual.Value);
            }
            if (IdFilter.NotIn != null)
            {
                if (NotIn == null)
                {
                    NotIn = new List <long>();
                }
                NotIn.AddRange(IdFilter.NotIn);
            }
            if (In != null)
            {
                List <string> InPaths = Organizations.Where(o => In.Count == 0 || In.Contains(o.Id)).Select(o => o.Path).ToList();
                Organizations = Organizations.Where(o => InPaths.Any(p => o.Path.StartsWith(p))).ToList();
            }
            if (NotIn != null)
            {
                List <string> NotInPaths = Organizations.Where(o => NotIn.Count == 0 || NotIn.Contains(o.Id)).Select(o => o.Path).ToList();
                Organizations = Organizations.Where(o => !NotInPaths.Any(p => o.Path.StartsWith(p))).ToList();
            }
            return(Organizations.Select(o => o.Id).ToList());
        }
Example #2
0
        protected async Task <List <long> > FilterProductType(IProductTypeService ProductTypeService, ICurrentContext CurrentContext)
        {
            List <long> In    = null;
            List <long> NotIn = null;

            foreach (var currentFilter in CurrentContext.Filters)
            {
                List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
                foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
                {
                    if (FilterPermissionDefinition.Name == "ProductTypeId")
                    {
                        if (FilterPermissionDefinition.IdFilter.Equal != null)
                        {
                            if (In == null)
                            {
                                In = new List <long>();
                            }
                            In.Add(FilterPermissionDefinition.IdFilter.Equal.Value);
                        }
                        if (FilterPermissionDefinition.IdFilter.In != null)
                        {
                            if (In == null)
                            {
                                In = new List <long>();
                            }
                            In.AddRange(FilterPermissionDefinition.IdFilter.In);
                        }

                        if (FilterPermissionDefinition.IdFilter.NotEqual != null)
                        {
                            if (NotIn == null)
                            {
                                NotIn = new List <long>();
                            }
                            NotIn.Add(FilterPermissionDefinition.IdFilter.NotEqual.Value);
                        }
                        if (FilterPermissionDefinition.IdFilter.NotIn != null)
                        {
                            if (NotIn == null)
                            {
                                NotIn = new List <long>();
                            }
                            NotIn.AddRange(FilterPermissionDefinition.IdFilter.NotIn);
                        }
                    }
                }
            }

            List <ProductType> ProductTypes = await ProductTypeService.List(new ProductTypeFilter
            {
                Id = new IdFilter {
                    In = In, NotIn = NotIn
                },
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = ProductTypeSelect.Id,
            });

            List <long> ProductTypeIds = ProductTypes.Select(a => a.Id).ToList();

            return(ProductTypeIds);
        }
Example #3
0
        protected async Task <List <long> > FilterOrganization(IOrganizationService OrganizationService, ICurrentContext CurrentContext)
        {
            if (CurrentContext.Filters == null || CurrentContext.Filters.Count == 0)
            {
                return(new List <long>());
            }
            List <Organization> Organizations = await OrganizationService.List(new OrganizationFilter
            {
                Skip      = 0,
                Take      = int.MaxValue,
                Selects   = OrganizationSelect.ALL,
                OrderBy   = OrganizationOrder.Id,
                OrderType = OrderType.ASC
            });

            List <long> In    = null;
            List <long> NotIn = null;

            foreach (var currentFilter in CurrentContext.Filters)
            {
                List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
                foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
                {
                    if (FilterPermissionDefinition.Name == "OrganizationId")
                    {
                        if (FilterPermissionDefinition.IdFilter.Equal != null)
                        {
                            if (In == null)
                            {
                                In = new List <long>();
                            }
                            In.Add(FilterPermissionDefinition.IdFilter.Equal.Value);
                        }
                        if (FilterPermissionDefinition.IdFilter.In != null)
                        {
                            if (In == null)
                            {
                                In = new List <long>();
                            }
                            In.AddRange(FilterPermissionDefinition.IdFilter.In);
                        }

                        if (FilterPermissionDefinition.IdFilter.NotEqual != null)
                        {
                            if (NotIn == null)
                            {
                                NotIn = new List <long>();
                            }
                            NotIn.Add(FilterPermissionDefinition.IdFilter.NotEqual.Value);
                        }
                        if (FilterPermissionDefinition.IdFilter.NotIn != null)
                        {
                            if (NotIn == null)
                            {
                                NotIn = new List <long>();
                            }
                            NotIn.AddRange(FilterPermissionDefinition.IdFilter.NotIn);
                        }
                    }
                }
            }

            if (In != null)
            {
                List <string> InPaths = Organizations.Where(o => In.Count == 0 || In.Contains(o.Id)).Select(o => o.Path).ToList();
                Organizations = Organizations.Where(o => InPaths.Any(p => o.Path.StartsWith(p))).ToList();
            }
            if (NotIn != null)
            {
                List <string> NotInPaths = Organizations.Where(o => NotIn.Count == 0 || NotIn.Contains(o.Id)).Select(o => o.Path).ToList();
                Organizations = Organizations.Where(o => !NotInPaths.Any(p => o.Path.StartsWith(p))).ToList();
            }

            List <long> organizationIds = Organizations.Select(o => o.Id).ToList();

            return(organizationIds);
        }
Example #4
0
        protected async Task <List <long> > FilterStoreGrouping(IStoreGroupingService StoreGroupingService, ICurrentContext CurrentContext)
        {
            List <long> In    = null;
            List <long> NotIn = null;

            foreach (var currentFilter in CurrentContext.Filters)
            {
                List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
                foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
                {
                    if (FilterPermissionDefinition.Name == "StoreGroupingId")
                    {
                        if (FilterPermissionDefinition.IdFilter.Equal != null)
                        {
                            if (In == null)
                            {
                                In = new List <long>();
                            }
                            In.Add(FilterPermissionDefinition.IdFilter.Equal.Value);
                        }
                        if (FilterPermissionDefinition.IdFilter.In != null)
                        {
                            if (In == null)
                            {
                                In = new List <long>();
                            }
                            In.AddRange(FilterPermissionDefinition.IdFilter.In);
                        }

                        if (FilterPermissionDefinition.IdFilter.NotEqual != null)
                        {
                            if (NotIn == null)
                            {
                                NotIn = new List <long>();
                            }
                            NotIn.Add(FilterPermissionDefinition.IdFilter.NotEqual.Value);
                        }
                        if (FilterPermissionDefinition.IdFilter.NotIn != null)
                        {
                            if (NotIn == null)
                            {
                                NotIn = new List <long>();
                            }
                            NotIn.AddRange(FilterPermissionDefinition.IdFilter.NotIn);
                        }
                    }
                }
            }

            List <StoreGrouping> StoreGroupings = await StoreGroupingService.List(new StoreGroupingFilter
            {
                Id = new IdFilter {
                    In = In, NotIn = NotIn
                },
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = StoreGroupingSelect.Id,
            });

            List <long> StoreGroupingIds = StoreGroupings.Select(a => a.Id).ToList();

            return(StoreGroupingIds);
        }