@{ var roleName = ""; string[] userNames = new string[1]; string[] roleNames = new string[1]; if(IsPost){ // Create new role if(!Request["buttonCreateRole"].IsEmpty()){ roleName=Request["textRoleName"]; if(!Roles.RoleExists(roleName) && !roleName.IsEmpty()){ Roles.CreateRole(roleName); } } // if(buttonCreateRole) // Delete role if(!Request["buttonDeleteRole"].IsEmpty()){ roleName=Request["textRoleName"]; if(Roles.GetUsersInRole(roleName).Length == 0 && !roleName.IsEmpty()) { Roles.DeleteRole(roleName, true); // true means throw if any users are in this role } } // if(buttonDeleteRole) // Add user to role if(!Request["buttonAddUserToRole"].IsEmpty()){ userNames[0] = Request["selectUserName"]; roleNames[0] = Request["selectRoleName"]; if(!Roles.IsUserInRole(userNames[0], roleNames[0])){ Roles.AddUsersToRoles(userNames, roleNames); } } // if(buttonAddUserToRole) // Delete user from role if(!Request["buttonDeleteUserFromRole"].IsEmpty()){ userNames[0] = Request["selectUserName"]; roleNames[0] = Request["selectRoleName"]; if(Roles.IsUserInRole(userNames[0], roleNames[0])){ Roles.RemoveUsersFromRoles(userNames, roleNames); } } // if(buttonDeleteUseFromRole) } }