Documentation

User

Get Method

Syntax:

public IUser Get(int userId)

Parameters:

Parameter Type Description
userId int The user ID of the user to retrieve

Return value:

Type Description
IUser The user

Examples:

@{
    var user = this.Api.User.Get(1123);
}


Get Method

Syntax:

public IUser Get(string userName)

Parameters:

Parameter Type Description
userName string The user name of the user

Return value:

Type Description
IUser The user

Examples:

@{
    var user = this.Api.User.Get("TECHNET/jsmith");
}


GetAll Method

Syntax:

public IList<IUser> GetAll()

Parameters:

None

Return value:

Type Description
IList<IUser> The list of all users in the system

Examples:

<ul>
@foreach (var user in this.Api.User.GetAll())
{
    <li>@user.FullName</li>
}
</ul>


GetGroups Method

Syntax:

IList<IPage> GetGroups(int userId)

Parameters:

Parameter Type Description
userId int The user ID of the user whose groups are to be retrieved

Return value:

Type Description
IList<IPage> The list of all groups the user belongs to

Examples:

<ul>
@foreach (var group in this.Api.User.GetGroups(Model.CurrentUser.UserId))
{
    <li>group.Title.Get(Model.BestMatchingCulture)</li>
}
</ul>


GetCustomField Method

Syntax:

ICustomField GetCustomField(int userId, string templateId)

Parameters:

Parameter Type Description
userId int The user ID of the user whose groups are to be retrieved
templateId string The ID of the custom field. Can be determined by viewing the Template Id column of the Custom fields table in Administration.

Return value:

Type Description
ICustomField The custom field for the user

Examples:

@{
    var twitterUserName = Api.User.GetCustomField(Model.CurrentUser.UserId, "Socialmedia-Twitterusername");
}