示例#1
0
        /// <summary>
        /// Gets the model for the post
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static EditModel GetById(Guid id, bool draft = true)
        {
            EditModel m = new EditModel();
            m.Post = Paladino.Models.Post.GetSingle(id, draft);
            m.Template = PostTemplate.GetSingle(m.Post.TemplateId);
            m.Permalink = Permalink.GetSingle(m.Post.PermalinkId);
            Category.GetByPostId(m.Post.Id, draft).ForEach(c => m.PostCategories.Add(c.Id));
            m.Categories = new MultiSelectList(Category.GetFields("category_id, category_name",
                new Params() { OrderBy = "category_name" }), "Id", "Name", m.PostCategories);
            m.GetRelated();

            return m;
        }
示例#2
0
        /// <summary>
        /// Creates a new post from the given template and return it 
        /// as a edit model.
        /// </summary>
        /// <param name="templateId">The template id</param>
        /// <returns>The edit model</returns>
        public static EditModel CreateByTemplate(Guid templateId)
        {
            EditModel m = new EditModel();

            m.Template = PostTemplate.GetSingle(templateId);
            m.Permalink = new Permalink()
            {
                Id = Guid.NewGuid(),
                Type = Permalink.PermalinkType.POST,
                NamespaceId = Config.DefaultNamespaceId
            };
            m.Post = new Paladino.Models.Post()
            {
                Id = Guid.NewGuid(),
                TemplateId = templateId,
                PermalinkId = m.Permalink.Id,
                AllowRss = m.Template.AllowRss
            };
            m.GetRelated();

            return m;
        }