Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Created January 23, 2015 13:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nul800sebastiaan/311e7f5f2332eb73d98d to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/311e7f5f2332eb73d98d to your computer and use it in GitHub Desktop.
// Get the type by type alias (aka. document type alias)
var type = Services.ContentTypeService.GetContentType("statusUpdate");
// Get the 10 latest nodes (based on create date) of the type from the "type"-object
// and create a list of StatusUpdates
var statusUpdates = Services.ContentService
.GetContentOfContentType(type.Id).OrderByDescending(x => x.CreateDate).Take(10);
var content = new List<StatusUpdate>();
foreach (var statusUpdate in statusUpdates)
{
// If the memberId is 0, then the posted was made when anonymous posts were still
// allowed; otherwise, use the memberservice to get the member’s name
var memberId = statusUpdate.GetValue<int>("memberId");
var memberName = memberId == 0
? "Guest"
: Services.MemberService.GetById(memberId).Name;
content.Add(new StatusUpdate
{
Id = statusUpdate.Id,
Text = statusUpdate.GetValue<string>("bodyText"),
CreateDate = statusUpdate.CreateDate.ToString(),
MemberName = memberName
});
}
return content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment