Пример #1
0
        public ActionResult GetsParentsService(ServiceTemplateTreeSearchModel model)
        {
            AllItems = db.ServiceTemplateTrees.Where(w => w.ProjectTreeRef == model.ProjectTreeRef & w.ServiceTemplateTreeRef == null & w.Level == "2").ToList();
            //AllItems = JsonConvert.DeserializeObject<List<ServiceTemplateTreeModel>>(JsonConvert.SerializeObject(select));

            var filtered = AllItems;

            if (model.Title != null)
            {
                filtered = filtered.Where(x => x.Title.Contains(model.Title)).ToList();
            }
            if (model.Description != null)
            {
                filtered = filtered.Where(x => x.Description.Contains(model.Description)).ToList();
            }
            PagedList <ServiceTemplateTreeModel> result = new PagedList <ServiceTemplateTreeModel>();


            var a = filtered.Skip((model.PageIndex * model.PageSize)).Take(model.PageSize).ToList();

            result.Items           = filtered.Skip((model.PageIndex * model.PageSize)).Take(model.PageSize).ToList();
            result.PageIndex       = model.PageIndex;
            result.PageSize        = model.PageSize;
            result.TotalItemsCount = filtered.Count;
            return(Ok(result));
        }
Пример #2
0
        public ActionResult GetAllPaged(ServiceTemplateTreeSearchModel model)
        {
            var select = db.ProjectTrees.Select(s => new { s.Title, s.State, s.ProjectTreeId, ProjectParent = s.ProjectTreechild.Title, s.ReginalPowerCorpRef, s.Code, s.Description, s.Level, s.LevelCode, ReginalPowerCorpTitle = s.ReginalPowerCorp.Title });

            AllItems = JsonConvert.DeserializeObject <List <ServiceTemplateTreeModel> >(JsonConvert.SerializeObject(select));

            var filtered = AllItems;

            if (model.Title != null)
            {
                filtered = filtered.Where(x => x.Title.Contains(model.Title)).ToList();
            }
            if (model.Description != null)
            {
                filtered = filtered.Where(x => x.Description.Contains(model.Description)).ToList();
            }
            PagedList <ServiceTemplateTreeModel> result = new PagedList <ServiceTemplateTreeModel>();


            var a = filtered.Skip((model.PageIndex * model.PageSize)).Take(model.PageSize).ToList();

            result.Items           = filtered.Skip((model.PageIndex * model.PageSize)).Take(model.PageSize).ToList();
            result.PageIndex       = model.PageIndex;
            result.PageSize        = model.PageSize;
            result.TotalItemsCount = filtered.Count;
            return(Ok(result));
        }