/* Database operations */
        /* Insert */
        public void Add(Page p)
        {
            try
            {
                using (_db)
                {
                    if (p.IDMasterPage != _masterPageId)
                        CheckMasterPageStatus(p);
                    else
                        p.MasterPage = _db.MasterPage.Single(x => x.ID == p.IDMasterPage);

                    _db.Page.InsertOnSubmit(p);

                    Commit();

                    SelectObjectsFromDb();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("error: inserting new page with title " + p.Title + " - " + ex.Message + " ...");
            }
        }
        private Page Copy(Page p, int newMasterPageId)
        {
            try
            {
                using (_db)
                {
                    Page pNew = new Page();

                    pNew.Name = p.Name + "CLONE";
                    pNew.IDMasterPage = newMasterPageId;
                    pNew.Options = p.Options;
                    pNew.Title = p.Title;
                    pNew.XMLFolderPath = p.XMLFolderPath;
                    pNew.XMLURL = p.XMLURL;

                    return pNew;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
 private void Page_Detach(Page entity)
 {
     this.SendPropertyChanging();
     entity.MasterPage = null;
 }
 /// <summary>
 /// Check if page has got a master page to connect.
 /// </summary>
 /// <param name="p"></param>
 private void CheckMasterPageStatus(Page p)
 {
     if (_masterPageId >= 0)
     {
         p.IDMasterPage = _masterPageId;
         p.MasterPage = _db.MasterPage.Single(x => x.ID == _masterPageId);
     }
     else
     {
         if (p.IDMasterPage >= 0)
         {
             if (p.MasterPage == null || p.IDMasterPage != p.MasterPage.ID)
             {
                 p.MasterPage = _db.MasterPage.Single(x => x.ID == p.IDMasterPage);
             }
         }
         else
             throw new Exception("no master page selected with the id " + p.IDMasterPage);
     }
 }
Ejemplo n.º 5
0
 private void Page_Attach(Page entity)
 {
     this.SendPropertyChanging();
     entity.MasterPage = this;
 }