Created
January 23, 2015 13:36
-
-
Save nul800sebastiaan/311e7f5f2332eb73d98d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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