Ejemplo n.º 1
0
        /// <summary>
        /// 按用户查询其所对应的角色中的用户列表
        /// </summary>
        public ActionResult UserList()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.SysUser.UserList();
                if (Request["UserType"] != null)
                {
                    Code.EnumHelper.SysUserType userType;
                    Enum.TryParse(Request["UserType"], out userType);
                    vm.UserType = userType;
                }

                var tb = db.Table <Sys.Entity.tbSysUser>();

                if (string.IsNullOrEmpty(vm.SearchText) == false)
                {
                    tb = tb.Where(d => d.UserCode.Contains(vm.SearchText) || d.UserName.Contains(vm.SearchText) || d.IdentityNumber.Contains(vm.SearchText) || d.Mobile.Contains(vm.SearchText) || d.Email.Contains(vm.SearchText) || d.Qq.Contains(vm.SearchText));
                }
                if (vm.UserType != null)
                {
                    tb = tb.Where(d => d.UserType == vm.UserType);
                }

                vm.DataList = (from p in tb
                               where p.UserType != Code.EnumHelper.SysUserType.Administrator
                               orderby p.UserName
                               select new Dto.SysUser.UserList
                {
                    Id = p.Id,
                    IsDisable = p.IsDisable,
                    IsLock = p.IsLock,
                    SexName = p.tbSex.SexName,
                    UserCode = p.UserCode,
                    UserName = p.UserName
                }).ToPageList(vm.Page);
                return(View(vm));
            }
        }
Ejemplo n.º 2
0
 public ActionResult UserList(Models.SysUser.UserList vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("UserList", new { userType = vm.UserType, searchText = vm.SearchText, pageIndex = vm.Page.PageIndex, pageSize = vm.Page.PageSize })));
 }