-
Notifications
You must be signed in to change notification settings - Fork 6
Members
Erik W edited this page Mar 17, 2016
·
2 revisions
Member POCO objects are supported to map to Umbraco Members. Similar to documents, you create properties on your POCO to map to properties on the member objects in the Umbraco database.
Example:
[UmbracoEntity]
public class MembersViewModel : CmsViewModelBase
{
[UmbracoMemberProperty("singleMember")]
public WebsiteUser User { get; set; }
}
[UmbracoMemberEntity(AutoMap = true)]
public class WebsiteUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public IMember MemberContent { get; set; }
public bool Approved
{
get { return MemberContent.IsApproved; }
}
}
These can be accessed directly or via mapped objects on your Umbraco document POCOs or pulled from Vault directly.
@using UmbracoVault
@model MembersViewModel
@{
var me = Vault.Context.GetMemberById<WebsiteUser>(1130);
}
<table>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr>
<td>FirstName</td>
<td>@me.FirstName</td>
</tr>
<tr>
<td>Last Name</td>
<td>@me.LastName</td>
</tr>
</table>
Hardcoded load by id is same as from ViewModel:
@(me.FirstName == Model.User.FirstName && me.LastName == Model.User.LastName && me.Age == Model.User.Age)