Ejemplo n.º 1
0
        public ActionResult Edit_Post(string id, string pageTitle, string pageFriendlyURL, string published)
        {
            Page Page = new Page();

            bool SavedIt = false;

            try
            {
                if (!string.IsNullOrWhiteSpace(id))
                {
                    Page = PageDAO.LoadByBsonId(id);
                }
                else
                {
                    Page.CreateDefaultNewPage();
                }

                Page.PageTitle       = pageTitle;
                Page.PageFriendlyURL = pageFriendlyURL;
                Page.Published       = Boolean.Parse(published);

                Page PageFriendlyURLExists = PageDAO.LoadByURL(Page.PageFriendlyURL);

                //can only save if another page type does not have the same page friendly url
                if (PageFriendlyURLExists == null || PageFriendlyURLExists.PageId.Equals(Page.PageId))
                {
                    SavedIt = true;

                    AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated page."), SUCCESS_MESSAGE_TYPE);

                    PageDAO.Save(Page);
                }
                else
                {
                    AddWebUserMessageToSession(Request, String.Format("Unable to save page, there is already a page type published with the friendly URL \"{0}\"", Page.PageFriendlyURL), FAILED_MESSAGE_TYPE);
                }
            }
            catch (Exception e)
            {
                Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.Edit_Post()" + e.Message);
            }

            //if we were trying to add a new page and were unable to save it
            if (string.IsNullOrWhiteSpace(id) && !SavedIt)
            {
                return(RedirectToAction("Dashboard", "Home"));
            }

            return(RedirectToAction("ViewPageHistory", "Page", new { pageId = Page.PageId }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load the requested page from the app cache
        /// </summary>
        /// <param name="friendlyURL"></param>
        /// <returns></returns>
        public static Page GetPageFromCache(string friendlyURL)
        {
            Page Page = new Page();

            Dictionary <string, Page> CurrentPageDictionary = PageDictionary;

            if (!PageDictionary.ContainsKey(friendlyURL))
            {
                Page = PageDAO.LoadByURL(friendlyURL);

                if (!string.IsNullOrWhiteSpace(Page.Id))
                {
                    CurrentPageDictionary.Add(Page.PageFriendlyURL, Page);

                    PageDictionary = CurrentPageDictionary;
                }
            }
            else
            {
                Page = CurrentPageDictionary[friendlyURL];
            }

            return(Page);
        }