Beispiel #1
0
        /// <summary>
        /// Creates a new page from the given template and position and returns it
        /// as an edit model.
        /// </summary>
        /// <param name="templateId">The template id</param>
        /// <param name="parentId">The parent id</param>
        /// <param name="seqno">The position sequence number</param>
        /// <param name="siteTreeId">The id of the site tree</param>
        /// <param name="siteTree">The internal id of the site tree</param>
        /// <returns>The edit model</returns>
        public static EditModel CreateByTemplateAndPosition(Guid templateId, Guid parentId, int seqno, Guid siteTreeId, string siteTree)
        {
            EditModel m = new EditModel();

            m.Page = new Paladino.Models.Page()
            {
                Id = Guid.NewGuid(),
                TemplateId = templateId,
                SiteTreeId = siteTreeId,
                SiteTreeInternalId = siteTree,
                ParentId = parentId,
                Seqno = seqno
            };
            m.GetRelated();

            return m;
        }
Beispiel #2
0
        /// <summary>
        /// Gets the model for the page specified by the given id.
        /// </summary>
        /// <param name="id">The page id</param>
        /// <param name="draft">Whether to get the draft or not.</param>
        /// <returns>The model</returns>
        public static EditModel GetById(Guid id, bool draft = true)
        {
            EditModel m = new EditModel();

            m.Page = Paladino.Models.Page.GetSingle(id, draft);
            if (m.Page == null)
                m.Page = Paladino.Models.Page.GetSingle(id);

            if (m.Page != null)
            {
                m.GetRelated();
                m.CanDelete = Page.GetScalar("SELECT count(*) FROM page WHERE page_parent_id=@0", id) == 0;
            }
            else throw new ArgumentException("Could not find page with id {" + id.ToString() + "}");

            return m;
        }
Beispiel #3
0
        public static EditModel CreateByOriginalAndPosition(Guid originalId, Guid parentId, int seqno, Guid siteTreeId, string siteTree)
        {
            var m = new EditModel();
            var p = Page.GetSingle(originalId, true);

            m.Page = new Paladino.Models.Page()
            {
                Id = Guid.NewGuid(),
                Title = p.Title,
                NavigationTitle = p.NavigationTitle,
                TemplateId = p.TemplateId,
                OriginalId = originalId,
                SiteTreeId = siteTreeId,
                SiteTreeInternalId = siteTree,
                ParentId = parentId,
                Seqno = seqno,
                PageController = p.PageController,
                PageRedirect = p.PageRedirect
            };
            m.GetRelated();

            return m;
        }