public IQueryable <CatPartnerModel> GetMultiplePartnerGroup(PartnerMultiCriteria criteria)
        {
            IQueryable <CatPartnerModel> data = Get();

            if (criteria == null)
            {
                return(data);
            }
            List <string> grpCodes = new List <string>();

            if (criteria.PartnerGroups != null)
            {
                foreach (var grp in criteria.PartnerGroups)
                {
                    string group = PlaceTypeEx.GetPartnerGroup(grp);
                    grpCodes.Add(group);
                }
                Expression <Func <CatPartnerModel, bool> > query = null;
                foreach (var group in grpCodes.Distinct())
                {
                    if (query == null)
                    {
                        query = x => (x.PartnerGroup ?? "").IndexOf(group ?? "", StringComparison.OrdinalIgnoreCase) >= 0;
                    }
                    else
                    {
                        query = query.Or(x => (x.PartnerGroup ?? "").IndexOf(group ?? "", StringComparison.OrdinalIgnoreCase) >= 0);
                    }
                }
                query = criteria.Active != null?query.And(x => x.Active == criteria.Active) : query;

                data = data.Where(query);
            }
            else
            {
                data = data.Where(x => x.Active == criteria.Active || criteria.Active == null);
            }
            return(data);
        }
Esempio n. 2
0
        public IActionResult GetMultiplePartnerGroup(PartnerMultiCriteria criteria)
        {
            var data = catPartnerService.GetMultiplePartnerGroup(criteria);

            return(Ok(data));
        }