Exemplo n.º 1
0
        protected void btnApply_Click(object sender, EventArgs e)
        {
            MembershipRole role = new MembershipRole(txtRoleName.Text, groupID);

            if (!Roles.RoleExists(txtRoleName.Text) && groupID == Guid.Empty)
            {
                Roles.CreateRole(txtRoleName.Text);
            }

            if (Roles.RoleExists(txtRoleName.Text) || groupID != Guid.Empty)
            {
                if (groupID == Guid.Empty)
                {
                    role = SecurityData.FindMembershipRole(txtRoleName.Text);

                    groupID = role.RoleId;
                }
                else
                {
                    role = SecurityData.FindMembershipRole(groupID);
                }

                if (role != null && groupID != Guid.Empty)
                {
                    if (CheckValidEditing(role.LoweredRoleName) &&
                        CheckValidEditing(txtRoleName.Text))
                    {
                        role.RoleName = txtRoleName.Text;
                        role.Save();
                    }

                    if (CheckValidEditing(role.LoweredRoleName) &&
                        !CheckValidEditing(txtRoleName.Text))
                    {
                        txtRoleName.Text = role.RoleName;
                    }
                }

                Response.Redirect(SiteData.CurrentScriptName + "?id=" + groupID.ToString());
            }
        }
Exemplo n.º 2
0
        protected MembershipRole getCurrentGroup()
        {
            MembershipRole role = SecurityData.FindMembershipRole(groupID);

            return(role);
        }