Esempio n. 1
0
        //workflow state 1 == unpublished
        //workflow state 2 == published
        //workflow state 3 == expired
        //workflow state 4 == deleted non - permanent
        //pageType 1 == normal content page
        //pageType 2 == Forms Page
        //pageType 3 == FAQ Page
        public static void Create(Page m_Page)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT IDENT_CURRENT('CMS_Pages')";
            SqlCommand getPageId = new SqlCommand(queryString, conn);
            int m_PageId = (int)(decimal)getPageId.ExecuteScalar();
            conn.Close();

            if (m_PageId == 1)
            {
                conn.Open();
                queryString = "SELECT COUNT(*) FROM CMS_Pages";
                SqlCommand getPageCount = new SqlCommand(queryString, conn);
                int pageCount = (int)getPageCount.ExecuteScalar();

                if (m_PageId == pageCount)
                {
                    m_PageId = pageCount + 1;
                }
                conn.Close();
            }
            else
            {
                m_PageId++;
            }

            int sortOrder = getSortOrder(m_Page.ParentId);

            conn.Open();

            queryString = "INSERT INTO CMS_Pages(pageId, contentGroup, templateId, pageTitle, navigationName, publishDate, expireDate, content, metaDescription, metaKeywords, parentId, pageWorkFlowState, lockedBy, lastModifiedBy, lastModifiedDate, sortOrder, redirectURL, pageType, pageTypeId, displayOnSubmenu, bannerImage) VALUES(@pageId, @contentGroup, @templateId, @pageTitle, @navigationName, @publishDate, @expireDate, @content, @metaDescription, @metaKeywords, @parentId, 1, @lockedBy, @lastModifiedBy, @lastModifiedDate, @sortOrder, @redirectURL, @pageType, @pageTypeId, @displayOnSubmenu, @bannerImage)";
            SqlCommand insertPage = new SqlCommand(queryString, conn);
            insertPage.Parameters.AddWithValue("pageId", m_PageId);
            insertPage.Parameters.AddWithValue("contentGroup", m_Page.ContentGroup);
            insertPage.Parameters.AddWithValue("templateId", m_Page.TemplateId);
            insertPage.Parameters.AddWithValue("pageTitle", m_Page.PageTitle);
            insertPage.Parameters.AddWithValue("navigationName", m_Page.NavigationName);
            insertPage.Parameters.AddWithValue("publishDate", m_Page.PublishDate.ToString());
            insertPage.Parameters.AddWithValue("expireDate", m_Page.ExpireDate.ToString());
            insertPage.Parameters.AddWithValue("content", m_Page.Content ?? string.Empty);
            insertPage.Parameters.AddWithValue("metaDescription", m_Page.MetaDescription ?? string.Empty);
            insertPage.Parameters.AddWithValue("metaKeywords", m_Page.MetaKeywords ?? string.Empty);
            insertPage.Parameters.AddWithValue("parentId", m_Page.ParentId);
            insertPage.Parameters.AddWithValue("lockedBy", HttpContext.Current.Session["uid"]);
            insertPage.Parameters.AddWithValue("lastModifiedBy", HttpContext.Current.Session["uid"]);
            insertPage.Parameters.AddWithValue("lastModifiedDate", DateTime.Now);
            insertPage.Parameters.AddWithValue("sortOrder", sortOrder);
            insertPage.Parameters.AddWithValue("redirectURL", m_Page.RedirectURL);
            insertPage.Parameters.AddWithValue("pageType", m_Page.PageType);
            insertPage.Parameters.AddWithValue("pageTypeId", m_Page.PageTypeId);
            insertPage.Parameters.AddWithValue("displayOnSubmenu", m_Page.DisplayOnSubmenu);
            insertPage.Parameters.AddWithValue("bannerImage", m_Page.BannerImageName ?? "");
            insertPage.ExecuteNonQuery();

            conn.Close();
        }
Esempio n. 2
0
        public void Update(Page m_Page)
        {
            Page tempPage = DBPage.RetrieveOne(m_Page.Id);
            m_Page.SortOrder = tempPage.SortOrder;
            m_Page.PageWorkFlowState = tempPage.PageWorkFlowState;
            m_Page.LockedBy = Utility.GetLockedBy(m_Page.Id);

            DBPage.Update(m_Page);
        }
Esempio n. 3
0
        public void Create(Page m_Page)
        {
            if (m_Page.FriendlyURL == "" || m_Page.FriendlyURL == null)
            {
                m_Page.FriendlyURL = "";
            }

            DBPage.Create(m_Page);
        }
Esempio n. 4
0
        public ActionResult AddPage(int id = 0)
        {
            ViewBag.ParentId = id;
            ViewBag.myContentGroups = Utility.ContentGroups();
            ViewBag.Templates = Utility.GetTemplates();
            ViewBag.BannerImages = ImageRepository.RetrieveAll(24);

            Page m_Page = new Page();

            return View("AddPage", m_Page);
        }
Esempio n. 5
0
        public ActionResult AddPage(Page m_Page)
        {
            if (m_Page.ParentId != 0)
            {
                var ExpireDate = ModelState["ExpireDate"];
                ExpireDate.Errors.Clear();
            }

            if (m_Page.ParentId > 0)
            {
                if (DateTime.Compare(m_Page.PublishDate, m_Page.ExpireDate) > 0 && m_Page.ExpireDate != DateTime.MinValue)
                {
                    ModelState.AddModelError("PublishDate", "Invalid publish date. The date select is not before the expire date");
                }
            }
            else
            {
                if (m_Page.ExpireDate != DateTime.MinValue)
                {
                    ModelState.AddModelError("ExpireDate", "You cannot set an expiration date to a top level page");
                }
            }

            if (m_Page.FriendlyURL != null && m_Page.FriendlyURL != string.Empty)
            {
                if (PageRepository.friendlyURLExists(m_Page.FriendlyURL, m_Page.PageID))
                {
                    ModelState.AddModelError("FriendlyURL", "This Friendly URL already exists");
                }
            }

            if (ModelState.IsValid)
            {
                m_Page.PageSetDefaults();
                PageRepository.Create(m_Page);
                return RedirectToAction("Index", "Page", new { id = m_Page.ParentId });
            }
            else
            {
                ViewBag.ParentId = m_Page.ParentId;
                ViewBag.myContentGroups = Utility.ContentGroups();
                ViewBag.Templates = Utility.GetTemplates();
                ViewBag.BannerImages = ImageRepository.RetrieveAll(24);
                ViewBag.Widgets = WidgetContainerRepository.RetrieveAll();

                return View("AddPage", m_Page);
            }
        }
Esempio n. 6
0
        public ActionResult getPageTypeIds(int mPageType, int id = 0)
        {
            ViewBag.PageType = mPageType;

            Page m_Page = new Page();

            if (id != 0)
            {
                m_Page = PageRepository.RetrieveOne(id);
            }

            ViewBag.m_Page = m_Page;

            if (mPageType == 2)
            {
                List<Form> m_Forms = FormRepository.RetrieveAll();
                return View("getForms", m_Forms);
            }
            else if (mPageType == 3)
            {
                List<FAQ> m_FAQ = FAQRepository.RetrieveAllFAQ();
                return View("getFAQ", m_FAQ);
            }
            else if (mPageType == 4)
            {
                List<Category> m_Categories = BlogPostRepository.getCategories();
                return View("getCategories", m_Categories);
            }
            else
            {
                ViewBag.Templates = Utility.GetTemplates();
                return View("getDefaults");
            }
        }
Esempio n. 7
0
 public void Create(Page m_Page)
 {
     DBPage.Create(m_Page);
 }
Esempio n. 8
0
        public void Update(Page m_Page)
        {
            Page tempPage = DBPage.getTopByPageId(m_Page.PageID);
            m_Page.SortOrder = tempPage.SortOrder;
            m_Page.PageWorkFlowState = tempPage.PageWorkFlowState;

            if (m_Page.Id != tempPage.Id)
            {
                m_Page.Id = tempPage.Id;
            }
            if (m_Page.FriendlyURL == "" || m_Page.FriendlyURL == null)
            {
                m_Page.FriendlyURL = "";
            }

            m_Page.LockedBy = Utility.GetLockedBy(m_Page.Id);

            DBPage.Update(m_Page);
        }
Esempio n. 9
0
        public static void Update(Page m_Page)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            if (m_Page.PageWorkFlowState == 1)
            {
                string queryString = "UPDATE CMS_Pages SET contentGroup = @contentGroup, templateId = @templateId, pageTitle = @pageTitle, navigationName = @navigationName, publishDate = @publishDate, expireDate = @expireDate, content = @content, metaDescription = @metaDescription, metaKeywords = @metaKeywords, parentId = @parentId, pageWorkFlowState = 1, lockedBy = @lockedBy, lastModifiedBy = @lastModifiedBy, lastModifiedDate = @lastModifiedDate, redirectURL = @redirectURL, pageType= @pageType, pageTypeId = @pageTypeId, displayOnSubmenu = @displayOnSubmenu, bannerImage = @bannerImage WHERE id = @id and pageId = @pageId";
                SqlCommand updatePage = new SqlCommand(queryString, conn);

                updatePage.Parameters.AddWithValue("contentGroup", m_Page.ContentGroup);
                updatePage.Parameters.AddWithValue("templateId", m_Page.TemplateId);
                updatePage.Parameters.AddWithValue("pageTitle", m_Page.PageTitle);
                updatePage.Parameters.AddWithValue("navigationName", m_Page.NavigationName);
                updatePage.Parameters.AddWithValue("publishDate", m_Page.PublishDate.ToString());
                updatePage.Parameters.AddWithValue("expireDate", m_Page.ExpireDate.ToString());
                updatePage.Parameters.AddWithValue("content", m_Page.Content ?? string.Empty);
                updatePage.Parameters.AddWithValue("metaDescription", m_Page.MetaDescription ?? string.Empty);
                updatePage.Parameters.AddWithValue("metaKeywords", m_Page.MetaKeywords ?? string.Empty);
                updatePage.Parameters.AddWithValue("parentId", m_Page.ParentId);
                updatePage.Parameters.AddWithValue("lockedBy", HttpContext.Current.Session["uid"]);
                updatePage.Parameters.AddWithValue("id", m_Page.Id);
                updatePage.Parameters.AddWithValue("PageId", m_Page.PageID);
                updatePage.Parameters.AddWithValue("lastModifiedBy", HttpContext.Current.Session["uid"]);
                updatePage.Parameters.AddWithValue("lastModifiedDate", DateTime.Now);
                updatePage.Parameters.AddWithValue("redirectURL", m_Page.RedirectURL);
                updatePage.Parameters.AddWithValue("pageType", m_Page.PageType);
                updatePage.Parameters.AddWithValue("pageTypeId", m_Page.PageTypeId);
                updatePage.Parameters.AddWithValue("displayOnSubmenu", m_Page.DisplayOnSubmenu);
                updatePage.Parameters.AddWithValue("bannerImage", m_Page.BannerImageName ?? "");

                updatePage.ExecuteNonQuery();
            }
            else if (m_Page.PageWorkFlowState == 2 || m_Page.PageWorkFlowState == 3)
            {
                string queryString = "INSERT INTO CMS_Pages(pageId, contentGroup, templateId, pageTitle, navigationName, publishDate, expireDate, content, metaDescription, metaKeywords, parentId, pageWorkFlowState, lockedBy, lastModifiedBy, lastModifiedDate, sortOrder, redirectURL, pageType, pageTypeId, displayOnSubmenu, bannerImage) VALUES(@pageId, @contentGroup, @templateId, @pageTitle, @navigationName, @publishDate, @expireDate, @content, @metaDescription, @metaKeywords, @parentId, 1, @lockedBy, @lastModifiedBy, @lastModifiedDate, @sortOrder, @redirectURL, @pageType, @pageTypeId, @displayOnSubmenu, @bannerImage)";
                SqlCommand insertPage = new SqlCommand(queryString, conn);
                insertPage.Parameters.AddWithValue("pageId", m_Page.PageID);
                insertPage.Parameters.AddWithValue("contentGroup", m_Page.ContentGroup);
                insertPage.Parameters.AddWithValue("templateId", m_Page.TemplateId);
                insertPage.Parameters.AddWithValue("pageTitle", m_Page.PageTitle);
                insertPage.Parameters.AddWithValue("navigationName", m_Page.NavigationName);
                insertPage.Parameters.AddWithValue("publishDate", m_Page.PublishDate.ToString());
                insertPage.Parameters.AddWithValue("expireDate", m_Page.ExpireDate.ToString());
                insertPage.Parameters.AddWithValue("content", m_Page.Content ?? string.Empty);
                insertPage.Parameters.AddWithValue("metaDescription", m_Page.MetaDescription ?? string.Empty);
                insertPage.Parameters.AddWithValue("metaKeywords", m_Page.MetaKeywords ?? string.Empty);
                insertPage.Parameters.AddWithValue("parentId", m_Page.ParentId);
                insertPage.Parameters.AddWithValue("lockedBy", HttpContext.Current.Session["uid"]);
                insertPage.Parameters.AddWithValue("lastModifiedBy", HttpContext.Current.Session["uid"]);
                insertPage.Parameters.AddWithValue("lastModifiedDate", DateTime.Now);
                insertPage.Parameters.AddWithValue("sortOrder", m_Page.SortOrder);
                insertPage.Parameters.AddWithValue("redirectURL", m_Page.RedirectURL);
                insertPage.Parameters.AddWithValue("pageType", m_Page.PageType);
                insertPage.Parameters.AddWithValue("pageTypeId", m_Page.PageTypeId);
                insertPage.Parameters.AddWithValue("displayOnSubmenu", m_Page.DisplayOnSubmenu);
                insertPage.Parameters.AddWithValue("bannerImage", m_Page.BannerImageName ?? "");
                insertPage.ExecuteNonQuery();
            }
            else
            {

            }

            conn.Close();
        }
Esempio n. 10
0
        public static Page RetrieveOne(int m_Id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString;
            string action = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
            string controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
            if (action == "PagePreview")
            {
                queryString = "SELECT * FROM CMS_Pages WHERE id = @id";
            }
            else if (controller == "Home" || controller == "")
            {
                queryString = "SELECT * FROM CMS_Pages WHERE pageId = @id AND pageWorkFlowState = 2 ORDER BY id DESC";
            }
            else
            {
                queryString = "SELECT * FROM CMS_Pages WHERE id = @id AND pageWorkFlowState != 4";
            }
            SqlCommand getPages = new SqlCommand(queryString, conn);
            getPages.Parameters.AddWithValue("id", m_Id);
            SqlDataReader pageDataReader = getPages.ExecuteReader();

            Page m_Page = new Page();

            if (pageDataReader.Read())
            {
                m_Page.Id = pageDataReader.GetInt32(0);
                m_Page.PageID = pageDataReader.GetInt32(1);
                m_Page.ContentGroup = pageDataReader.GetInt32(2);
                m_Page.TemplateId = pageDataReader.GetInt32(3);
                m_Page.PageTitle = pageDataReader.GetString(4);
                m_Page.NavigationName = pageDataReader.GetString(5);
                m_Page.PublishDate = pageDataReader.GetDateTime(6);
                m_Page.ExpireDate = pageDataReader.GetDateTime(7);
                m_Page.Content = pageDataReader.GetString(8);
                m_Page.MetaDescription = pageDataReader.GetString(9);
                m_Page.MetaKeywords = pageDataReader.GetString(10);
                m_Page.ParentId = pageDataReader.GetInt32(11);
                m_Page.PageWorkFlowState = pageDataReader.GetInt32(12);
                m_Page.LockedBy = pageDataReader.GetInt32(13);
                m_Page.SortOrder = pageDataReader.GetInt32(16);
                m_Page.RedirectURL = pageDataReader.GetString(17);
                m_Page.PageType = pageDataReader.GetInt32(18);
                m_Page.PageTypeId = pageDataReader.GetInt32(19);
                m_Page.LockedByName = DBPage.GetLockedByName(m_Page.LockedBy);
                m_Page.DisplayOnSubmenu = pageDataReader.GetInt32(20);
                m_Page.BannerImageName = pageDataReader.GetString(21);

                if (!pageDataReader.IsDBNull(17))
                {
                    m_Page.RedirectURL = pageDataReader.GetString(17);
                }
            }

            conn.Close();
            return m_Page;
        }
Esempio n. 11
0
        public static List<Page> RetrieveAll(int m_Id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
            string queryString = "";

            if (controller == "Home" || controller == "")
            {
                queryString = "SELECT * FROM CMS_Pages WHERE parentId = @parentId AND pageWorkFlowState = 2 order by sortOrder, pageId, id DESC";
                //queryString = "SELECT * FROM CMS_Pages WHERE pageId = @id AND pageWorkFlowState = 2 ORDER BY id DESC";
            }
            else
            {
                queryString = "SELECT * FROM CMS_Pages WHERE parentId = @parentId AND pageWorkFlowState != 4 order by sortOrder, pageId, id DESC";
            }

            SqlCommand getPages = new SqlCommand(queryString, conn);
            getPages.Parameters.AddWithValue("parentId", m_Id);
            SqlDataReader pagesDataReader = getPages.ExecuteReader();

            List<Page> m_Pages = new List<Page>();
            int previousPageId = 0;

            while (pagesDataReader.Read())
            {
                Page tempPage = new Page();

                tempPage.Id = pagesDataReader.GetInt32(0);
                tempPage.PageID = pagesDataReader.GetInt32(1);
                tempPage.ContentGroup = pagesDataReader.GetInt32(2);
                tempPage.TemplateId = pagesDataReader.GetInt32(3);
                tempPage.PageTitle = pagesDataReader.GetString(4);
                tempPage.NavigationName = pagesDataReader.GetString(5);
                tempPage.PublishDate = pagesDataReader.GetDateTime(6);
                tempPage.ExpireDate = pagesDataReader.GetDateTime(7);
                tempPage.Content = pagesDataReader.GetString(8);
                tempPage.MetaDescription = pagesDataReader.GetString(9);
                tempPage.MetaKeywords = pagesDataReader.GetString(10);
                tempPage.ParentId = pagesDataReader.GetInt32(11);
                tempPage.PageWorkFlowState = pagesDataReader.GetInt32(12);
                tempPage.LockedBy = pagesDataReader.GetInt32(13);
                tempPage.SortOrder = pagesDataReader.GetInt32(16);
                tempPage.LockedByName = DBPage.GetLockedByName(tempPage.LockedBy);
                tempPage.DisplayOnSubmenu = pagesDataReader.GetInt32(20);
                tempPage.BannerImageName = pagesDataReader.GetString(21);

                if (!pagesDataReader.IsDBNull(17))
                {
                    tempPage.RedirectURL = pagesDataReader.GetString(17);
                }

                if (previousPageId != tempPage.PageID)
                {
                    m_Pages.Add(tempPage);
                }

                previousPageId = tempPage.PageID;

            }

            conn.Close();
            return m_Pages;
        }
Esempio n. 12
0
        public ActionResult Index(string friendlyURL, int id = 0)
        {
            string[] ip_address = Request.UserHostAddress.Split('.');
            if (ip_address.Length == 4 && ip_address[0] != "127")
            {
                string m_Network = ip_address[0] + "." + ip_address[1] + "." + ip_address[2];
                ViewBag.Network = m_Network;
            }

            if (id == 0 && friendlyURL == "Home")
            {
                Page m_Page = PageRepository.RetrieveOne(39);
                ViewBag.TemplateId = 4;
                ViewBag.PageId = 39;
                return View("Home", m_Page);
            }
            else
            {
                Page m_Page = new Page();

                if (friendlyURL == null)
                {
                    m_Page = PageRepository.RetrieveOne(id);
                }
                else
                {
                    m_Page = PageRepository.RetrieveOneByFriendlyURL(friendlyURL);
                }

                if (m_Page == null || m_Page.TemplateName == null || m_Page.TemplateName == "")
                {
                    return View("404");
                }
                else
                {
                    if (m_Page.RedirectURL == null || m_Page.RedirectURL == string.Empty)
                    {
                        ViewBag.PageType = m_Page.PageType;
                        ViewBag.id = m_Page.PageTypeId;
                        ViewBag.PageId = m_Page.PageID;
                        ViewBag.TemplateId = m_Page.TemplateId;

                        return View(m_Page.TemplateName, m_Page);
                    }
                    else
                    {
                        return Redirect(m_Page.RedirectURL);
                    }
                }
            }
        }
Esempio n. 13
0
        public ActionResult EditPage(Page m_Page)
        {
            if (m_Page.ParentId > 0)
            {
                var ExpireDate = ModelState["ExpireDate"];
                ExpireDate.Errors.Clear();
            }
            if (m_Page.ParentId > 0)
            {
                if (DateTime.Compare(m_Page.PublishDate, m_Page.ExpireDate) > 0 && m_Page.ExpireDate != DateTime.MinValue)
                {
                    ModelState.AddModelError("PublishDate", "Invalid publish date. The date select is not before the expire date");
                }
            }
            else
            {
                if (m_Page.ExpireDate != DateTime.MinValue)
                {
                    ModelState.AddModelError("ExpireDate", "You cannot set an expiration date to a top level page");
                }
            }

            if (Utility.GetLockedBy(m_Page.Id) != (int)System.Web.HttpContext.Current.Session["uid"])
            {
                return RedirectToAction("Index", "Page", new { id = m_Page.ParentId });
            }

            if (ModelState.IsValid)
            {
                m_Page.PageSetDefaults();
                PageRepository.Update(m_Page);
                return RedirectToAction("Index", "Page", new { id = m_Page.ParentId });
            }
            else
            {
                ViewBag.ParentId = m_Page.ParentId;
                ViewBag.myContentGroups = Utility.ContentGroups();
                ViewBag.Templates = Utility.GetTemplates();
                ViewBag.BannerImages = ImageRepository.RetrieveAll(24);

                return View("EditPage", m_Page);
            }
        }
Esempio n. 14
0
        public static Page RetrieveOneByFriendlyURL(string friendlyURL)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_Pages WHERE friendlyURL = @friendlyURL AND pageWorkFlowState = 2 AND (expireDate > @expireDate OR expireDate = '0001-01-01') ORDER BY id DESC";

            SqlCommand getPages = new SqlCommand(queryString, conn);
            getPages.Parameters.AddWithValue("friendlyURL", friendlyURL);
            getPages.Parameters.AddWithValue("expireDate", DateTime.Now);

            SqlDataReader pageDataReader = getPages.ExecuteReader();

            Page m_Page = new Page();

            if (pageDataReader.Read())
            {
                m_Page.Id = pageDataReader.GetInt32(0);
                m_Page.PageID = pageDataReader.GetInt32(1);
                m_Page.ContentGroup = pageDataReader.GetInt32(2);
                m_Page.TemplateId = pageDataReader.GetInt32(3);
                m_Page.PageTitle = pageDataReader.GetString(4);
                m_Page.NavigationName = pageDataReader.GetString(5);
                m_Page.PublishDate = pageDataReader.GetDateTime(6);
                m_Page.ExpireDate = pageDataReader.GetDateTime(7);
                m_Page.Content = pageDataReader.GetString(8);
                m_Page.MetaDescription = pageDataReader.GetString(9);
                m_Page.MetaKeywords = pageDataReader.GetString(10);
                m_Page.ParentId = pageDataReader.GetInt32(11);
                m_Page.PageWorkFlowState = pageDataReader.GetInt32(12);
                m_Page.LockedBy = pageDataReader.GetInt32(13);
                m_Page.SortOrder = pageDataReader.GetInt32(16);
                m_Page.RedirectURL = pageDataReader.GetString(17);
                m_Page.PageType = pageDataReader.GetInt32(18);
                m_Page.PageTypeId = pageDataReader.GetInt32(19);
                m_Page.LockedByName = DBPage.GetLockedByName(m_Page.LockedBy);
                m_Page.DisplayOnSubmenu = pageDataReader.GetInt32(20);
                m_Page.BannerImageName = pageDataReader.GetString(21);
                m_Page.FriendlyURL = pageDataReader.GetString(22);
                m_Page.WidgetContainerId = pageDataReader.GetInt32(23);
                m_Page.DisplaySocialMedia = pageDataReader.GetInt16(24);

                if (!pageDataReader.IsDBNull(17))
                {
                    m_Page.RedirectURL = pageDataReader.GetString(17);
                }
            }

            conn.Close();
            return m_Page;
        }
Esempio n. 15
0
        public static Page getTopByPageId(int pageId)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT TOP 1 * FROM CMS_Pages WHERE pageId = @pageId ORDER BY id DESC";
            SqlCommand getPage = new SqlCommand(queryString, conn);
            getPage.Parameters.AddWithValue("pageId", pageId);
            SqlDataReader pageDataReader = getPage.ExecuteReader();

            Page m_Page = new Page();

            if (pageDataReader.Read())
            {
                m_Page.Id = pageDataReader.GetInt32(0);
                m_Page.PageID = pageDataReader.GetInt32(1);
                m_Page.ContentGroup = pageDataReader.GetInt32(2);
                m_Page.TemplateId = pageDataReader.GetInt32(3);
                m_Page.PageTitle = pageDataReader.GetString(4);
                m_Page.NavigationName = pageDataReader.GetString(5);
                m_Page.PublishDate = pageDataReader.GetDateTime(6);
                m_Page.ExpireDate = pageDataReader.GetDateTime(7);
                m_Page.Content = pageDataReader.GetString(8);
                m_Page.MetaDescription = pageDataReader.GetString(9);
                m_Page.MetaKeywords = pageDataReader.GetString(10);
                m_Page.ParentId = pageDataReader.GetInt32(11);
                m_Page.PageWorkFlowState = pageDataReader.GetInt32(12);
                m_Page.LockedBy = pageDataReader.GetInt32(13);
                m_Page.SortOrder = pageDataReader.GetInt32(16);
                m_Page.RedirectURL = pageDataReader.GetString(17);
                m_Page.PageType = pageDataReader.GetInt32(18);
                m_Page.PageTypeId = pageDataReader.GetInt32(19);
                m_Page.LockedByName = DBPage.GetLockedByName(m_Page.LockedBy);
                m_Page.DisplayOnSubmenu = pageDataReader.GetInt32(20);
                m_Page.BannerImageName = pageDataReader.GetString(21);
                m_Page.DisplaySocialMedia = (int)pageDataReader.GetInt16(24);

                if (!pageDataReader.IsDBNull(17))
                {
                    m_Page.RedirectURL = pageDataReader.GetString(17);
                }
            }

            conn.Close();

            return m_Page;
        }