Database Reference
In-Depth Information
Adding a Status Update
The page shown in Figure 7-6 shows the form to add a status update for the current user, which is displayed when
clicking on the “Add Content” link just under the “Graph Story - Social Feed” header. The HTML for the form can
be found in {PROJECTROOT}/Views/Social/Posts.cshtml . The form uses the addContent function in graphstory.
js to POST a new status update as well as return the response and add it to the top of the status update stream. In the
SocialController , use the add method to pass the content to the service layer, as shown in Listing 7-32.
Figure 7-6. Adding a status update
Listing 7-32. The add Method in the Social Controller
// add content
[HttpPost]
public JsonResult add(Content jsonObj) {
MappedContent mappedContent = graphStoryService.contentInterface.add(jsonObj,graphstoryUserAuth
Value);
mappedContent.userNameForPost = graphstoryUserAuthValue;
return Json(jsonObj,JsonRequestBehavior.AllowGet);
}
The add method for ContentService is shown in Listing 7-32. When a new status update is created, in addition to
its graph id, the add method also generates a contentId, which is performed using the Guid.NewGuid method.
 
Search WWH ::




Custom Search