Пример #1
0
        public static TopicPermission Parse(PERMISSION permission)
        {
            TopicPermission result = new TopicPermission();

            result._id = (int)permission;
            return(result);
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
 public List <Role> GetRolesForPermission(TopicPermission permission)
 {
     return(_listAuthentication[permission]);
 }