Exemple #1
0
        /// <summary>
        /// Gets the related information for the post.
        /// </summary>
        private void GetRelated()
        {
            var post = (Post)Post;

            if (post == null)
            {
                return;
            }

            PostTemplate pt = PostTemplate.GetSingle(((Post)Post).TemplateId);

            // Get categories
            Categories = Category.GetByPostId(Post.Id);

            // Properties
            if (pt.Properties.Count > 0)
            {
                foreach (string str in pt.Properties)
                {
                    ((IDictionary <string, object>)Properties).Add(str, "");
                }
                Property.GetContentByParentId(Post.Id, ((Post)Post).IsDraft).ForEach(pr => {
                    if (((IDictionary <string, object>)Properties).ContainsKey(pr.Name))
                    {
                        ((IDictionary <string, object>)Properties)[pr.Name] = pr.Value;
                    }
                });
            }

            // Attachments
            ((Models.Post)Post).Attachments.ForEach(a => Attachments.Add(Models.Content.GetSingle(a, ((Post)Post).IsDraft)));

            // Extensions
            foreach (var ext in ((Post)Post).GetExtensions())
            {
                object body = ext.Body;
                if (body != null)
                {
                    var getContent = body.GetType().GetMethod("GetContent");
                    if (getContent != null)
                    {
                        body = getContent.Invoke(body, new object[] { this });
                    }
                }
                ((IDictionary <string, object>)Extensions)[ExtensionManager.Current.GetInternalIdByType(ext.Type)] = body;
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the related information for the post.
        /// </summary>
        private void GetRelated()
        {
            PostTemplate pt = PostTemplate.GetSingle(((Post)Post).TemplateId);

            // Get categories
            Categories = Category.GetByPostId(Post.Id);

            // Properties
            if (pt.Properties.Count > 0)
            {
                foreach (string str in pt.Properties)
                {
                    ((IDictionary <string, object>)Properties).Add(str, "");
                }
                Property.GetContentByParentId(Post.Id, ((Post)Post).IsDraft).ForEach(pr => {
                    if (((IDictionary <string, object>)Properties).ContainsKey(pr.Name))
                    {
                        ((IDictionary <string, object>)Properties)[pr.Name] = pr.Value;
                    }
                });
            }
            // Attachments
            ((Models.Post)Post).Attachments.ForEach(a => Attachments.Add(Models.Content.GetSingle(a)));
        }