GetIdFromClientId() public static method

public static GetIdFromClientId ( string clientId ) : int
clientId string
return int
Beispiel #1
0
        // ================================================================================================ 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(string.Format("JournalId:{0}", 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, item.When, itemID, postInfo.Type, sharedContent, postInfo.Details);
                }
            }
            else
            {
                post = Node.LoadNode(itemID);
            }
            return(post);
        }
Beispiel #2
0
        public ActionResult GetLikeList(string itemId, string rnd)
        {
            if (!HasPermission())
            {
                return(Json("Please log in to see who liked this item!", JsonRequestBehavior.AllowGet));
            }

            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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        public static string GetLikeList(Content content, string itemId, string rnd)
        {
            if (!HasPermission())
            {
                return(JsonConvert.SerializeObject(SNSR.GetString(Compatibility.SR.Wall.PleaseLogIn)));
            }

            SetCurrentWorkspace(content.Path);
            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(likelist.ToString());
        }