示例#1
0
 public IQueryable<User> BulidQuery(IQueryable<User> query, UserSearchModel model)
 {
     if (model.Role != null)
         query = query.Where(u => u.Role == model.Role);
     if (!string.IsNullOrEmpty(model.Search))
         query = query.Where(u => u.UserName.Contains(model.Search) || u.NiceName.Contains(model.Search));
     return query;
 }
示例#2
0
 public UserSearchModel Build(int pageIndex = 0)
 {
     UserSearchModel model = new UserSearchModel() { Search = Search, Role = Role, PageIndex = PageIndex, PageSize = PageSize };
     if (pageIndex != 0)
     {
         model.PageIndex = pageIndex;
     }
     return model;
 }
        public UserSearchModel Build(int pageIndex = 0)
        {
            UserSearchModel model = new UserSearchModel()
            {
                Search = Search, Role = Role, PageIndex = PageIndex, PageSize = PageSize
            };

            if (pageIndex != 0)
            {
                model.PageIndex = pageIndex;
            }
            return(model);
        }
示例#4
0
        public ActionResult Index(UserSearchModel model, string message = null, string method = null, int[] userIds = null)
        {
            ///操作判断开始
            if (!string.IsNullOrEmpty(method))
            {
                if (method.Equals("Delete"))
                {
                    return DeleteList(userIds);
                }
            }
            ViewBag.Message = message;
            ///取得每页显示数            
            int pageSize = int.Parse(_settingService.GetSetting("AdminUserPageSize"));
            if (model.PageSize != null && model.PageSize > 0 && model.PageSize != pageSize)
            {
                _settingService.SetSetting("AdminUserPageSize", model.PageSize.ToString());
            }
            else
            {
                model.PageSize = pageSize;
            }
            PageInfo<User> pageInfo = new PageInfo<User>();
            int count = (int)_userService.Single(query => BulidQuery(query, model).Count());


            model.AllCount = (int)_userService.Single(query => query.Count());
            model.AdminCount = (int)_userService.Single(query => query.Where(u => u.Role == UserRole.Admin).Count());
            model.ReaderCount = (int)_userService.Single(query => query.Where(u => u.Role == UserRole.Reader).Count());

            pageInfo.TotalItem = count;
            pageInfo.PageSize = model.PageSize.Value;

            model.PageIndex = model.PageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : model.PageIndex;
			model.PageIndex = model.PageIndex <= 0 ? 1 : model.PageIndex ;
            IList<User> list = _userService.Find(query => BulidQuery(query, model).OrderByDescending(c => c.RegisterDate).Skip((model.PageIndex - 1) * model.PageSize.Value).Take(model.PageSize.Value));
            pageInfo.PageItems = list;
            model.PageInfo = pageInfo;
            return View(model);
        }