Exemplo n.º 1
0
        public ActionResult EditUserList(Guid groupId, List <string> users)
        {
            var pList = new List <Guid>();

            foreach (var s in users)
            {
                Guid id;
                if (Guid.TryParse(s, out id))
                {
                    pList.Add(id);
                }
            }

            if (pList.Count > 0)
            {
                _roleGroupService.UpdateGroupUsers(groupId, pList);
            }

            return(Json(new AjaxResponse
            {
                Succeeded = true,
                ShowMessage = true,
                Message = CommonResource.Msg_Operate_Ok,
                RedirectUrl = string.Empty
            }));
        }
        public ActionResult EditUserList(Guid groupId, List <string> users)
        {
            return(HttpHandleExtensions.AjaxCallGetResult(() =>
            {
                var pList = new List <Guid>();

                foreach (var s in users.OpSafe())
                {
                    Guid id;
                    if (Guid.TryParse(s, out id))
                    {
                        pList.Add(id);
                    }
                }

                // 清除用户缓存
                var oldUsers = _roleGroupService.GetUsersIdName(groupId);

                _roleGroupService.UpdateGroupUsers(groupId, pList);

                // 清除用户缓存
                foreach (var u in oldUsers)
                {
                    AuthorizeManager.ClearUserCache(u.Id);
                }
                foreach (var id in pList)
                {
                    AuthorizeManager.ClearUserCache(id);
                }

                this.JsMessage = MessagesResources.Update_Success;
                return Json(new AjaxResponse
                {
                    Succeeded = true,
                    RedirectUrl = Url.Action("EditUserList", new
                    {
                        groupId
                    })
                });
            }));
        }