-
Notifications
You must be signed in to change notification settings - Fork 2
Users and Usergroups
There are currently 2 classes involved that are representing the data model of an elitepvpers user: User
being the base class and PremiumUser
, the advanced version which is used for representing users that subscribed to the premium abonnement.
The Usergroup
class contains data about the different user groups. We implemented several properties for default usergroups that are part of the system. If new ranks will be added somewhere in the future that is not contained in this library, you may just create your own Usergroup
object as follows:
var futureGroup= new Usergroup("Future Usegroup Name", "futuregroup.png", Usergroup.Rights.PrivateForumAccess);
For iterating through the different usergroups an user has, just use the IEnumerable<Usergroup>
property User.Usergroups
as follows:
User mostey = new User("Mostey", 467410);
mostey.Update(session);
foreach (var usergroup in mostey.Usergroups)
Console.WriteLine(String.Format("Name: {0} - AccessRights: {1} - Badge URL: {2}", usergroup.Name, usergroup.AccessRights, usergroup.Path));
The code above will iterate through all usergroups of the user Mostey and output some information about them. Note the call on mostey.Update(session)
which is required to update all information available. Otherwise, mostey.Usergroups
would never contain entries.
For searching users by name, you may use the static User.Search
function as follows:
var matchingUsers = User.Search(session, "Mostey");
The above sample code will perform a search request and return all users that contain the letters Mostey
in any way and store the unique user id into the returned objects.
In case you need a single user that matches the exact name, use the User.ByName
function instead:
var match = User.ByName(session, "Mostey"); // the match variable will contain the user that matched the specified name
Please note that this function will only update the User.ID
property. You wanna call User.Update
in order to receive more information.