public JsonResult getData(int indexPage, string sortQuery, int pageSize) { var searchModel = SessionManager.GetValue(KeySearchModelSession) as DotTuyenDungSearchDTO; if (!string.IsNullOrEmpty(sortQuery)) { if (searchModel == null) { searchModel = new DotTuyenDungSearchDTO(); } searchModel.sortQuery = sortQuery; if (pageSize > 0) { searchModel.pageSize = pageSize; } SessionManager.SetValue(KeySearchModelSession, searchModel); } var data = _DotTuyenDungService.GetDaTaByPage(searchModel, indexPage, pageSize); return(Json(data)); }
public JsonResult searchData(FormCollection form) { var searchModel = SessionManager.GetValue(KeySearchModelSession) as DotTuyenDungSearchDTO; if (searchModel == null) { searchModel = new DotTuyenDungSearchDTO(); searchModel.pageSize = 20; } searchModel.seaTenDot = form["seaTenDot"]; searchModel.seaTrangThai = form["seaTrangThai"]; searchModel.ngaybatdaufrom = form["ngaybatdaufrom"].ToDateTime(); searchModel.ngaybatdauto = form["ngaybatdauto"].ToDateTime(); searchModel.ngayketthucfrom = form["ngayketthucfrom"].ToDateTime(); searchModel.ngayketthucto = form["ngayketthucto"].ToDateTime(); SessionManager.SetValue(KeySearchModelSession, searchModel); var data = _DotTuyenDungService.GetDaTaByPage(searchModel, 1, searchModel.pageSize); return(Json(data)); }
public PageListResultBO <DotTuyenDungDTO> GetDaTaByPage(DotTuyenDungSearchDTO searchModel, int pageIndex = 1, int pageSize = 20) { var query = _DotTuyenDungRepository.GetAllAsQueryable(); if (searchModel != null) { if (!string.IsNullOrEmpty(searchModel.seaTenDot)) { searchModel.seaTenDot = searchModel.seaTenDot.Trim().ToLower(); query = query.Where(x => x.TenDot.Trim().ToLower().Contains(searchModel.seaTenDot)); } if (searchModel.seaTrangThai != "") { query = query.Where(x => x.TrangThai == searchModel.seaTrangThai); } if (searchModel.ngaybatdaufrom != null) { query = query.Where(x => x.NgayBatDau >= searchModel.ngaybatdaufrom); } if (searchModel.ngaybatdauto != null) { query = query.Where(x => x.NgayBatDau <= searchModel.ngaybatdauto); } if (searchModel.ngayketthucfrom != null) { query = query.Where(x => x.NgayKetThuc >= searchModel.ngayketthucfrom); } if (searchModel.ngayketthucto != null) { query = query.Where(x => x.NgayKetThuc <= searchModel.ngayketthucto); } 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_DotTuyenDung>(); 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 <DotTuyenDungDTO> >(resultmodel)); }