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

            result._id = (int)permission;
            return(result);
        }
        public void RemovePermission(TopicPermission topicpermission, Role role)
        {
            _listAuthentication[topicpermission].Remove(role);
            Database database = new Database("PSCPortalConnectionString");

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = database.GetCommand(connection);
                #region TopicId
                DbParameter prTopicId = database.GetParameter(System.Data.DbType.Guid, "@TopicId", _topic.Id);
                command.Parameters.Add(prTopicId);
                #endregion

                #region TopicPermissionId
                DbParameter prTopicPermissionId = database.GetParameter(System.Data.DbType.Int32, "@TopicPermissionId", topicpermission.Id);
                command.Parameters.Add(prTopicPermissionId);
                #endregion

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

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

                connection.Open();
                command.ExecuteNonQuery();
            }
        }
        public bool IsAllow(TopicPermission.PERMISSION permission)
        {
            if (System.Web.HttpContext.Current.User.IsInRole(System.Configuration.ConfigurationManager.AppSettings["GroupAdmin"]))
            {
                return(true);
            }

            List <Role> listRole = GetRolesForPermission(TopicPermission.Parse(permission));

            foreach (Role role in listRole)
            {
                if (System.Web.HttpContext.Current.User.IsInRole(role.Name))
                {
                    return(true);
                }
            }
            return(false);
        }
 public List <Role> GetRolesForPermission(TopicPermission permission)
 {
     return(_listAuthentication[permission]);
 }