Ejemplo n.º 1
0
        public JsonResult searchData(FormCollection form)
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            var searchModel = SessionManager.GetValue("thuoctinhSearch") as TAILIEU_THUOCTINH_SEARCH;

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

            searchModel.LOAI_TAILIEU  = form["LOAI_TAILIEU"].ToIntOrZero();
            searchModel.TEN_THUOCTINH = form["TEN_THUOCTINH"];
            if (!string.IsNullOrEmpty(form["TRANGTHAI"]))
            {
                searchModel.TRANGTHAI = form["TRANGTHAI"].Equals("1");
            }
            else
            {
                searchModel.TRANGTHAI = null;
            }
            SessionManager.SetValue("thuoctinhSearch", searchModel);
            var data = LOAITAILIEU_THUOCTINHBusiness.GetDaTaByPage(searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }
Ejemplo n.º 2
0
        public PageListResultBO <LOAITAILIEU_THUOCTINH_BO> GetDaTaByPage(TAILIEU_THUOCTINH_SEARCH searchModel, int pageIndex = 1, int pageSize = 20)
        {
            var query = from thuoctinh in this.context.LOAITAILIEU_THUOCTINH
                        join danhmuc in this.context.DM_DANHMUC_DATA
                        on thuoctinh.DANHMUC_ID equals danhmuc.ID
                        into group1
                        from g1 in group1.DefaultIfEmpty()
                        select new LOAITAILIEU_THUOCTINH_BO
            {
                ID            = thuoctinh.ID,
                DANHMUC_ID    = thuoctinh.DANHMUC_ID,
                MOTA          = thuoctinh.MOTA,
                TEN_DANHMUC   = g1.TEXT,
                TEN_THUOCTINH = thuoctinh.TEN_THUOCTINH,
                TRANGTHAI     = thuoctinh.TRANGTHAI
            };

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.sortQuery))
                {
                    query = query.OrderBy(searchModel.sortQuery);
                }
                else
                {
                    query = query.OrderByDescending(x => x.TEN_DANHMUC);
                }
            }
            else
            {
                query = query.OrderByDescending(x => x.TEN_DANHMUC);
            }
            var resultmodel = new PageListResultBO <LOAITAILIEU_THUOCTINH_BO>();

            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(resultmodel);
        }
Ejemplo n.º 3
0
        public JsonResult getData(int indexPage, string sortQuery, int pageSize)
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            var searchModel = SessionManager.GetValue("thuoctinhSearch") as TAILIEU_THUOCTINH_SEARCH;

            if (!string.IsNullOrEmpty(sortQuery))
            {
                if (searchModel == null)
                {
                    searchModel = new TAILIEU_THUOCTINH_SEARCH();
                }
                searchModel.sortQuery = sortQuery;
                if (pageSize > 0)
                {
                    searchModel.pageSize = pageSize;
                }
                SessionManager.SetValue("thuoctinhSearch", searchModel);
            }
            var data = LOAITAILIEU_THUOCTINHBusiness.GetDaTaByPage(searchModel, indexPage, pageSize);

            return(Json(data));
        }