SenseNet.Portal.Wall.PostInfo.GetIdFromClientId C# (CSharp) Méthode

GetIdFromClientId() public static méthode

public static GetIdFromClientId ( string clientId ) : int
clientId string
Résultat int
        public static int GetIdFromClientId(string clientId)
        {
            var idStr = clientId;
            if (clientId.StartsWith("J"))
                idStr = clientId.Substring(1);
            return Convert.ToInt32(idStr);
        }
        public static bool IsJournalId(string clientId)

Usage Example

Exemple #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);
        }
All Usage Examples Of SenseNet.Portal.Wall.PostInfo::GetIdFromClientId