Beispiel #1
0
        public static PagePermission Parse(PERMISSION permission)
        {
            PagePermission result = new PagePermission();

            result._id = (int)permission;
            return(result);
        }
        public void RemovePermission(PagePermission Pagepermission, Role role)
        {
            _listAuthentication[Pagepermission].Remove(role);
            Database database = new Database("PSCPortalConnectionString");
            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = database.GetCommand(connection);
                #region PageId
                DbParameter prPageId = database.GetParameter(System.Data.DbType.Guid, "@PageId", _Page.Id);
                command.Parameters.Add(prPageId);
                #endregion

                #region PagePermissionId
                DbParameter prPagePermissionId = database.GetParameter(System.Data.DbType.Int32, "@PagePermissionId", Pagepermission.Id);
                command.Parameters.Add(prPagePermissionId);
                #endregion

                #region RoleId
                DbParameter prRoleId = database.GetParameter(System.Data.DbType.Guid, "@RoleId", role.Id);
                command.Parameters.Add(prRoleId);
                #endregion

                command.CommandText = "PageAuthentication_Delete";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                connection.Open();
                command.ExecuteNonQuery();
            }
        }
 public  bool IsAllow(PagePermission.PERMISSION permission)
 {
     if (System.Web.HttpContext.Current.User.IsInRole(System.Configuration.ConfigurationManager.AppSettings["GroupAdmin"]))
         return true;
     
     List<Role> listRole = GetRolesForPermission(PagePermission.Parse(permission));
     foreach (Role role in listRole)
         if (System.Web.HttpContext.Current.User.IsInRole(role.Name))
             return true;
     return false;
 }
 public List<Role> GetRolesForPermission(PagePermission permission)
 {
     return _listAuthentication[permission];
 }