public ActionResult RoleAuthority(RoleAuthority roleAuthority)
        {
            ViewData["roleTypeList"] = _listService.GetRoleTypeList();

            if (roleAuthority != null)
            {
                if (_roleAuthority.UpdateRoleAuthorityList(roleAuthority))
                {
                    ViewBag.Title = "修改成功,下次登录时生效";
                    return View("message");
                }
                ViewBag.Title = "修改失败";
            }
            return View("message");
        }
示例#2
0
 /// <summary>
 ///     根据角色类型id查看权限
 /// </summary>
 /// <param name="roleTypeId">角色id</param>
 /// <returns></returns>
 public RoleAuthority GetRoleAuthorityList(long roleTypeId)
 {
     var roleAuthorityService = new RoleAuthorityService();
     List<role_authority> roleAuthorityList = roleAuthorityService.FindByRoleTypeId(roleTypeId);
     var authorityList = new RoleAuthority();
     int i = 0;
     foreach (role_authority roleAuthority in roleAuthorityList.OrderBy(m => m.FunctionId))
     {
         authorityList.RoleAuthoritys.Add(new Authority());
         authorityList.RoleAuthoritys[i].Function = roleAuthority.function.Meno;
         authorityList.RoleAuthoritys[i].Add = roleAuthority.Add;
         authorityList.RoleAuthoritys[i].Check = roleAuthority.Check;
         authorityList.RoleAuthoritys[i].Delete = roleAuthority.Delete;
         authorityList.RoleAuthoritys[i].Edit = roleAuthority.Edit;
         i++;
     }
     return authorityList;
 }
示例#3
0
        /// <summary>
        ///     更新权限表
        /// </summary>
        /// <param name="authorityList"></param>
        /// <returns></returns>
        public bool UpdateRoleAuthorityList(RoleAuthority authorityList)
        {
            var roleAuthorityService = new RoleAuthorityService();
            List<role_authority> roleAuthorityList =
                roleAuthorityService.FindByRoleTypeId(long.Parse(authorityList.Role));

            int i = 0;
            foreach (role_authority roleAuthority in roleAuthorityList.OrderBy(m => m.FunctionId))
            {
                roleAuthority.Add = authorityList.RoleAuthoritys[i].Add;
                roleAuthority.Check = authorityList.RoleAuthoritys[i].Check;
                roleAuthority.Delete = authorityList.RoleAuthoritys[i].Delete;
                roleAuthority.Edit = authorityList.RoleAuthoritys[i].Edit;
                roleAuthority.Meno = authorityList.Meno;
                i++;
                roleAuthorityService.Update(roleAuthority);
            }
            return true;
        }