コード例 #1
0
        public PageListResultBO <CommonConfigurationDTO> GetDataByPage(CommonConfigurationSearchDTO searchParams, int pageIndex = 1, int pageSize = 20)
        {
            var query = (from tbl in this._commonConfigurationRepository.GetAllAsQueryable()
                         select new CommonConfigurationDTO()
            {
                Id = tbl.Id,
                ConfigCode = tbl.ConfigCode,
                ConfigName = tbl.ConfigName,
                ConfigData = tbl.ConfigData
            });

            if (searchParams != null)
            {
                if (!String.IsNullOrEmpty(searchParams.QueryCode))
                {
                    query = query.Where(x => x.ConfigCode.Contains(searchParams.QueryCode));
                }
                if (!String.IsNullOrEmpty(searchParams.QueryName))
                {
                    query = query.Where(x => x.ConfigName.Contains(searchParams.QueryName));
                }

                if (!string.IsNullOrEmpty(searchParams.sortQuery))
                {
                    query = query.OrderBy(searchParams.sortQuery);
                }
                else
                {
                    query = query.OrderByDescending(x => x.Id);
                }
            }
            else
            {
                query = query.OrderByDescending(x => x.Id);
            }

            var result = new PageListResultBO <CommonConfigurationDTO>();

            if (pageSize == -1)
            {
                var pagedList = query.ToList();
                result.Count     = pagedList.Count;
                result.TotalPage = 1;
                result.ListItem  = pagedList;
            }
            else
            {
                var dataPageList = query.ToPagedList(pageIndex, pageSize);
                result.Count     = dataPageList.TotalItemCount;
                result.TotalPage = dataPageList.PageCount;
                result.ListItem  = dataPageList.ToList();
            }
            return(result);
        }
コード例 #2
0
        public JsonResult SearchData(FormCollection form)
        {
            var searchModel = SessionManager.GetValue(SessionSearchString) as CommonConfigurationSearchDTO;

            if (searchModel == null)
            {
                searchModel          = new CommonConfigurationSearchDTO();
                searchModel.pageSize = 20;
            }

            searchModel.QueryName = form["QueryName"];
            searchModel.QueryCode = form["QueryCode"].ToUpper();
            SessionManager.SetValue(SessionSearchString, searchModel);
            var data = _commonConfigurationService.GetDataByPage(searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }
コード例 #3
0
        public JsonResult GetData(int indexPage, string sortQuery, int pageSize)
        {
            var searchModel = SessionManager.GetValue(SessionSearchString) as CommonConfigurationSearchDTO;

            if (searchModel == null)
            {
                searchModel = new CommonConfigurationSearchDTO();
            }
            if (!string.IsNullOrEmpty(sortQuery))
            {
                searchModel.sortQuery = sortQuery;
            }
            if (pageSize > 0)
            {
                searchModel.pageSize = pageSize;
            }
            SessionManager.SetValue(SessionSearchString, searchModel);
            var data = _commonConfigurationService.GetDataByPage(searchModel, indexPage, pageSize);

            return(Json(data));
        }