Database Reference
In-Depth Information
public string tagstr { get; set; }
public long timestamp { get; set; }
public string userNameForPost { get; set; }
private string TimestampAsStr;
public string timestampAsStr
{
get
{
System.DateTime datetime = new DateTime(1970, 1, 1, 0, 0, 0, 0,
System.DateTimeKind.Utc);
datetime = datetime.AddSeconds(this.timestamp).ToLocalTime();
this.timestampAsStr = datetime.ToString("MM/dd/yyyy") + " at " + datetime.
ToString("h:mm tt");
return TimestampAsStr;
}
set
{
TimestampAsStr = value;
}
}
public List<Tag> tags { get; set; }
public User user { get; set; }
public Content next { get; set; }
}
Getting Status Updates
To display the first set of status updates, start with the Index method inside of the SocialController . This method
accesses the getContent method within ContentService , which takes an argument of the GraphStory object, the
current user's username, the page being request and the number of items to be returned. The page refers to set
number of objects within a collection. In this instance the paging is zero-based, so you will request page 0 and limit
the page size to 3 in order to return the first page.
The getContent method in ContentService , shown in the first part of Listing 7-30, first determines whom
the user is following and then matches that set of users with the status updates, starting with the CURRENTPOST .
The CURRENTPOST is then matched on the next three status updates via the [:NEXTPOST*0..3] section of the query.
Finally, the query uses a ViewModel to return only the properties that are necessary to display back to the View in the
application.
Listing 7-30. The getContent Method in ContentService
public GraphStory getContent(GraphStory graphStory, string username, int page, int pagesize)
{
graphStory.content = _graphClient.Cypher.Match(" (u:User {username: {u} }) ")
.WithParam("u", username)
.With("u")
.Match(" (u)-[:FOLLOWS*0..1]->f ")
.With(" DISTINCT f,u ")
.Match(" f-[:CURRENTPOST]-lp-[:NEXTPOST*0..3]-p")
.Return(() => Return.As<MappedContent>("{contentId: p.contentId, title: p.title,
url: p.url," +
 
Search WWH ::




Custom Search