// ================================================================================================ Private methods /// <summary> /// Get a post from clientId. If it is a manual post, it comes from repository. /// If it is a journal post, it either comes from journal and a repository post is created, or is already persisted to repository. /// </summary> /// <param name="clientId"></param> /// <param name="contextPath">New posts from journal items will be created under contextPath</param> /// <returns></returns> private static Node GetPostFromId(string clientId, string contextPath) { Node post = null; var itemID = PostInfo.GetIdFromClientId(clientId); if (PostInfo.IsJournalId(clientId)) { // CRUD post, create a manual post // only create it if it is not yet created! post = ContentQuery.Query("JournalId:@0", null, itemID).Nodes.FirstOrDefault(); if (post == null) { var item = Journals.GetSingleItem(itemID); // lastpath is empty here: we wont use it from this scenario var postInfo = new PostInfo(item, string.Empty); var sharedContent = Node.LoadNode(item.NodeId); post = CreatePost(contextPath, postInfo.Text, itemID, postInfo.Type, sharedContent, postInfo.Details); } } else { post = Node.LoadNode(itemID); } return(post); }
public ActionResult GetLikeList(string itemId, string contextPath, string rnd) { if (!HasPermission()) { return(Json(SNSR.GetString(SNSR.Wall.PleaseLogIn), JsonRequestBehavior.AllowGet)); } SetCurrentWorkspace(contextPath); var id = PostInfo.GetIdFromClientId(itemId); // create like markup var likeInfo = new LikeInfo(id); var likelist = new StringBuilder(); foreach (var likeitem in likeInfo.LikeUsers) { var likeuser = likeitem as User; likelist.Append(WallHelper.GetLikeListItemMarkup(likeuser)); } return(Json(likelist.ToString(), JsonRequestBehavior.AllowGet)); }