public JsonResult SearchData(FormCollection form)
        {
            var searchModel = SessionManager.GetValue(SessionSearchString) as QuanLyMauTestSearchDTO;

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

            searchModel.QueryName         = form["QueryName"];
            searchModel.QueryCategoryList = form["QueryCategoryList"].ToListStringLower(',');
            SessionManager.SetValue(SessionSearchString, searchModel);
            var data = _quanLyMauTestService.GetDaTaByPage(searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }
        public PageListResultBO <QuanLyMauTestDTO> GetDaTaByPage(QuanLyMauTestSearchDTO searchModel, int pageIndex = 1, int pageSize = 20)
        {
            var query = _quanLyMauTestRepository.GetAllAsQueryable();

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.QueryName))
                {
                    query = query.Where(x => x.FileName.Contains(searchModel.QueryName));
                }
                if (searchModel.QueryCategoryList.Count > 0)
                {
                    query = query.Where(x => searchModel.QueryCategoryList.Contains(x.Category));
                }
                if (!string.IsNullOrEmpty(searchModel.sortQuery))
                {
                    query = query.OrderBy(searchModel.sortQuery);
                }
                else
                {
                    query = query.OrderByDescending(x => x.Id);
                }
            }
            else
            {
                query = query.OrderByDescending(x => x.Id);
            }
            var resultmodel = new PageListResultBO <TD_QuanLyMauTest>();

            if (pageSize == -1)
            {
                var dataPageList = query.ToList();
                resultmodel.Count     = dataPageList.Count;
                resultmodel.TotalPage = 1;
                resultmodel.ListItem  = dataPageList;
            }
            else
            {
                var dataPageList = query.ToPagedList(pageIndex, pageSize);
                resultmodel.Count     = dataPageList.TotalItemCount;
                resultmodel.TotalPage = dataPageList.PageCount;
                resultmodel.ListItem  = dataPageList.ToList();
            }

            return(_imapper.Map <PageListResultBO <QuanLyMauTestDTO> >(resultmodel));
        }
        public JsonResult GetData(long groupid, int indexPage, string sortQuery, int pageSize)
        {
            var searchModel = SessionManager.GetValue(SessionSearchString) as QuanLyMauTestSearchDTO;

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

            return(Json(data));
        }