Beispiel #1
0
        /// <summary>
        /// 查询是否有权限
        /// </summary>
        /// <param name="lRoleId"></param>
        /// <param name="controllerName"></param>
        /// <param name="actionName"></param>
        /// <returns></returns>
        private bool GetRoleAction(List <int> lRoleId, string controllerName, string actionName)
        {
            MenuActionRepository menuActionRep = new MenuActionRepository();
            string url = "/" + controllerName + "/" + actionName;

            if (!menuActionRep.Exist(m => m.ActionUrl == url))
            {
                return(false);
            }
            int intMenuActionID = menuActionRep.Find(m => m.ActionUrl == url).MenuActionID;
            RoleActionRepository roleActionRep = new RoleActionRepository();

            foreach (var roldID in lRoleId)
            {
                if (roleActionRep.Exist(r => r.MenuActionID == intMenuActionID && r.RoleID == roldID))
                {
                    return(true);
                }
            }
            return(false);
        }