Exemplo n.º 1
0
        public ActionResult List()
        {
            if (Code.Common.UserType != Code.EnumHelper.SysUserType.Administrator && Code.Common.UserType != Code.EnumHelper.SysUserType.Teacher)
            {
                return(Content(Code.Common.Redirect(Url.Action("Index", "SysIndex", new { area = "Sys" }), "当前身份类别无法访问该功能!")));
            }

            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.SysUser.List();
                if (Request["UserType"] != null)
                {
                    Code.EnumHelper.SysUserType userType;
                    Enum.TryParse(Request["UserType"], out userType);
                    vm.UserType = userType;
                }

                var tb = from p in db.Table <Sys.Entity.tbSysUser>()
                         select p;

                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.UserList = (from p in tb
                               orderby p.UserName
                               select new Dto.SysUser.List
                {
                    Id = p.Id,
                    UserCode = p.UserCode,
                    UserName = p.UserName,
                    UserType = p.UserType,
                    SexName = p.tbSex.SexName,
                    Email = p.Email,
                    IdentityNumber = p.IdentityNumber,
                    IsDisable = p.IsDisable,
                    IsLock = p.IsLock,
                    Mobile = p.Mobile,
                    Password = p.Password,
                    Qq = p.Qq,
                }).ToPageList(vm.Page);
                return(View(vm));
            }
        }
Exemplo n.º 2
0
 public ActionResult List(Models.SysUser.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new { userType = vm.UserType, searchText = vm.SearchText, pageIndex = vm.Page.PageIndex, pageSize = vm.Page.PageSize })));
 }