예제 #1
0
        /// <summary>
        /// Removes a role from the data source for the configured applicationName.
        /// </summary>
        /// <returns>
        /// true if the role was successfully deleted; otherwise, false.
        /// </returns>
        /// <param name="roleName">
        /// The name of the role to delete.
        /// </param>
        /// <param name="throwOnPopulatedRole">
        /// If true, throw an exception if roleName has one or more members and do not delete roleName.
        /// </param>
        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            if (BlogConfig.IsSystemRole(roleName))
            {
                for (var i = 0; i < this.roles.Count; i++)
                {
                    if (this.roles[i].Name != roleName)
                    {
                        continue;
                    }

                    this.roles.RemoveAt(i);
                    this.Save();
                    return(true);
                }
            }

            return(false);
        }