Exemplo n.º 1
0
        private PagedList<Employee> QueryListData(EmployeeSearch searchModel)
        {
            int recordCount = 0;
            int pageSize = ConstantManager.PageSize;
            EmployeeService service = new EmployeeService();

            string Group = searchModel.IsAsc ? searchModel.SortBy : searchModel.SortBy + " Descending";

            IList<Employee> allEntities = service.QueryByPage(this.GetSearchFilter(searchModel), Group, pageSize, searchModel.PageIndex + 1, out recordCount);

            var formCondition = "var condition=" + JsonConvert.SerializeObject(searchModel);
            return new PagedList<Employee>(allEntities, searchModel.PageIndex, pageSize, recordCount, "Id", "Id", formCondition);
        }
Exemplo n.º 2
0
 private void LoadSearchViewBag(EmployeeSearch searchModel)
 {
     #region sort
     ViewBag.IsAsc = !searchModel.IsAsc;
     ViewBag.SortBy = searchModel.SortBy;
     #endregion
         var departmentService = new DepartmentService();
         if (!searchModel.DepartmentId.HasValue)
         {
             ViewBag.DepartmentId = new SelectList(departmentService.Query(p => p.IsActive=="1"), "Id", "Name");
         }
         else
         {
             ViewBag.DepartmentId = new SelectList(departmentService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.DepartmentId);
         }
 }
Exemplo n.º 3
0
 public ActionResult SearchListPartialView(EmployeeSearch searchModel)
 {
     #region sort
     ViewBag.IsAsc = !searchModel.IsAsc;
     ViewBag.SortBy = searchModel.SortBy;
     #endregion
     return PartialView("SearchListPartialView",this.QueryListData(searchModel));
 }
Exemplo n.º 4
0
        private Expression<Func<Employee, bool>> GetSearchFilter(EmployeeSearch searchModel)
        {
            Expression<Func<Employee, bool>> filter = p => p.IsActive=="1" ;
                 if (searchModel.DepartmentId.HasValue)
                 {
                    filter = filter.And(q => q.DepartmentId == searchModel.DepartmentId.Value);
                 }

            return filter;
        }
Exemplo n.º 5
0
 //
 // GET: /Employee/
 //[PermissionFilter]
 public ViewResult Index(EmployeeSearch searchModel)
 {
     this.LoadSearchViewBag(searchModel);
     return View(this.QueryListData(searchModel));
 }