public JsonResult ChangePasswordPost(FormCollection collection)
        {
            var     service = new SysUserService();
            SysUser user    = service.Login(collection["UserCode"], collection["OldPwd"]);

            if (user == null || string.Compare(user.Pwd, collection["OldPwd"], false) != 0)
            {
                return(Json(new { success = false, msg = "<=OldPwdNotMatched>" }));
            }
            else
            {
                if (string.Compare(collection["NewPwd"], collection["ConfirmPwd"], false) != 0)
                {
                    return(Json(new { success = false, msg = "<=NewPwdNotMatched>" }));
                }

                if (string.Compare(collection["NewPwd"], user.Pwd, false) == 0)
                {
                    return(Json(new { success = false, msg = "<=ForbidMatchOldPwd>" }));
                }

                string errorMsg = string.Empty;
                user.PasswordDate = DateTime.Now.Date;

                user.Pwd = collection["NewPwd"];
                TryUpdateModel <SysUser>(user);

                //判断新密码规则,Operator不受密码规则控制
                var _sysUserRoleService = new SysUserRoleService();
                var _sysRoleService     = new SysRoleService();
                var sysUserRole         = _sysUserRoleService.GetList().Where(o => o.SysUserId == user.SysUserId).Select(o => o.SysRoleId).Distinct().ToList();
                var sysRole             = _sysRoleService.GetList().Where(o => sysUserRole.Contains(o.SysRoleId) || o.SysRoleId == user.RoleId).ToList();
                if (sysRole.Count() > 0 && (sysRole.Count() != 1 || sysRole.Where(o => o.RoleCode.Contains("Operator")).Count() <= 0))
                {
                    if (!this.PassWordIsValid(user.Pwd))
                    {
                        return(Json(new { success = false, msg = "<=PasswordError>" }, JsonRequestBehavior.AllowGet));
                    }
                }
                if (!ModelState.IsValid)
                {
                    List <string> errorList = ModelStateExtension.GetModelError(ViewData);
                    string        str       = string.Join(",", errorList.ToArray());
                    return(Json(new { success = false, msg = str }, JsonRequestBehavior.AllowGet));
                }
                bool success = service.Save(user, out errorMsg);
                if (!success)
                {
                    return(Json(new { success = false, msg = errorMsg }));
                }

                FormsService.SignIn(collection["UserCode"], false);
                return(Json(new { success = true, msg = "<=ModifySuccess>" }));
            }
        }
        private Expression <Func <QuestionManage, bool> > UserPredicate()
        {
            var req = new GridRequest(Request);
            Expression <Func <QuestionManage, bool> > predicate = FilterHelper.GetExpression <QuestionManage>(req.FilterGroup);
            //查找user信息
            var session = ControllerContext.HttpContext.Session;
            var user    = session["UserInfo"] as IUser <int>;
            var sysUser = user as SysUser;
            //查找role信息
            SysUserRoleService sysrole = new SysUserRoleService();
            var sysrolelist            = sysrole.Repository.Entities.Where(x => x.UserId == sysUser.Id).ToList();

            //从dictionary表中查询信息
            //var list = DictionaryService.QueryList(x => x.CategoryCode == "SERVICE_ONLINE").ToList();
            var list = thisList();
            //根据category过滤
            var categories = list.Where(x => x.accessRoleId.Split(',').Any(y => sysrolelist.Any(z => z.RoleId == int.Parse(y)))).Select(x => x.categoryCode).ToList();

            return(predicate.AndAlso(a => categories.Contains(a.Category)));
        }
 public SysUserRoleController(SysUserRoleService sysUserRoleService)
 {
     _sysUserRoleService = sysUserRoleService;
 }