public JsonResult SearchData(FormCollection form) { var searchModel = SessionManager.GetValue("OperationSearch") as OperationSearchDTO; if (searchModel == null) { searchModel = new OperationSearchDTO(); searchModel.pageSize = 20; } searchModel.QueryModuleId = int.Parse(form["QUERY_MODULE_ID"]); searchModel.QueryName = form["QUERY_NAME"]; searchModel.QueryIsShow = !string.IsNullOrEmpty(form["QUERY_SHOW"]) ? (bool?)(int.Parse(form["QUERY_SHOW"]) > 0) : null; SessionManager.SetValue("OperationSearch", searchModel); var data = _operationService.GetDataByPage(searchModel, 1); return(Json(data)); }
// GET: OperationArea/Operation public ActionResult Index(int moduleId) { var searchModel = new OperationSearchDTO() { QueryModuleId = moduleId }; SessionManager.SetValue("OperationSearch", searchModel); OperationIndexViewModel viewModel = new OperationIndexViewModel() { ModuleId = moduleId, GroupData = _operationService.GetDataByPage(searchModel), }; var name = _moduleService.GetById(moduleId); ViewBag.TenChucNang = name.Name; return(View(viewModel)); }
public JsonResult GetData(int indexPage, int moduleId, string sortQuery, int pageSize) { var searchModel = SessionManager.GetValue("OperationSearch") as OperationSearchDTO; if (searchModel == null) { searchModel = new OperationSearchDTO(); } searchModel.QueryModuleId = moduleId; if (!string.IsNullOrEmpty(sortQuery)) { searchModel.sortQuery = sortQuery; } if (pageSize > 0) { searchModel.pageSize = pageSize; } SessionManager.SetValue("OperationSearch", searchModel); var data = _operationService.GetDataByPage(searchModel, indexPage, pageSize); return(Json(data)); }
public PageListResultBO <OperationDTO> GetDataByPage(OperationSearchDTO searchParams, int pageIndex = 1, int pageSize = 20) { var queryResult = (from operation in this._operationRepository.GetAllAsQueryable() select new OperationDTO() { Id = operation.Id, Name = operation.Name, Code = operation.Code, URL = operation.URL, IsShow = operation.IsShow, ModuleId = operation.ModuleId, Order = operation.Order }); if (searchParams != null) { queryResult = queryResult.Where(x => x.ModuleId == searchParams.QueryModuleId); if (!string.IsNullOrEmpty(searchParams.QueryName)) { searchParams.QueryName = searchParams.QueryName.Trim().ToLower(); queryResult = queryResult.Where(x => x.Name.Trim().ToLower().Contains(searchParams.QueryName)); } if (searchParams.QueryIsShow != null) { queryResult = queryResult.Where(x => x.IsShow == searchParams.QueryIsShow.Value); } if (!string.IsNullOrEmpty(searchParams.sortQuery)) { queryResult = queryResult.OrderBy(searchParams.sortQuery); } else { queryResult = queryResult.OrderBy(x => x.Order) .ThenBy(x => x.Name); } } else { queryResult = queryResult.OrderBy(x => x.Order) .ThenBy(x => x.Name); } var result = new PageListResultBO <OperationDTO>(); if (pageSize == -1) { var pagedList = queryResult.ToList(); result.Count = pagedList.Count; result.TotalPage = 1; result.ListItem = pagedList; } else { var dataPageList = queryResult.ToPagedList(pageIndex, pageSize); result.Count = dataPageList.TotalItemCount; result.TotalPage = dataPageList.PageCount; result.ListItem = dataPageList.ToList(); } return(result); }