Пример #1
0
        /// <summary>
        /// Create a new page model.
        /// </summary>
        /// <param name="friendlyURL"></param>
        /// <param name="request"></param>
        public PageModel(string friendlyURL, HttpRequestBase request)
        {
            string id = !string.IsNullOrWhiteSpace(request["id"]) ? request["id"] : string.Empty;

            AdminUser AdminUser = SiteContext.User;

            //if a bson id was passed, and the admin user is not null, and they have the page edit role
            if (!string.IsNullOrWhiteSpace(id) && AdminUser != null && SiteContext.CanAdminUserAccess("page-edit"))
            {
                InEditMode = true;
                Page       = PageDAO.LoadByBsonId(id) ?? new Page();
            }
            else
            {
                InEditMode = Helpers.AppSettings.InDeveloperEditMode;

                //only continue if this is a regular page view outside of edit mode
                if (Page != null && !string.IsNullOrWhiteSpace(Page.Id) && !InEditMode)
                {
                    ChimeraWebsite.Helpers.SiteContext.RecordPageView(friendlyURL);
                }

                Page = ChimeraWebsite.Helpers.AppCache.GetPageFromCache(friendlyURL);
            }
        }
Пример #2
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 }));
        }
Пример #3
0
        public ActionResult Edit(string id)
        {
            try
            {
                Page Page = new Page();

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

                ViewBag.Page = Page;
            }
            catch (Exception e)
            {
                Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.Edit()" + e.Message);
            }

            return(View());
        }