Пример #1
0
        /// <summary>
        /// Retrieves the home page template model for the current domain.
        /// </summary>
        /// <param name="name">Holds the name of the model type that was retrieved.</param>
        /// <returns>The current domains home page template.</returns>
        public HomePageTemplate RetrieveHomePage(out string name)
        {
            DomainHomePage entity = Query.DomainHomePage(UserCookie.Current.DomainId);

            bool newNeeded = false;

            if (entity == null)
            {
                newNeeded = true;
                entity    = new DomainHomePage()
                {
                    ModelType = "Ribbon",
                    HomePage  = ""
                };
            }

            name = entity.ModelType;

            CachedEditableModel cachedModel = CMSCache.HomePages[entity.ModelType];

            HomePageTemplate homePage = JsonConvert.DeserializeObject(entity.HomePage, cachedModel.ModelType) as HomePageTemplate;

            if (newNeeded)
            {
                homePage = new Framework.Models.HomePage.Ribbon();
            }

            homePage.DisplayLocation = cachedModel.DisplayLocation;
            homePage.EditorLocation  = cachedModel.EditorLocation;

            return(homePage);
        }
Пример #2
0
        /// <summary>
        /// Gets the page template model, updated with the form data.
        /// </summary>
        /// <param name="cachedModel"></param>
        /// <returns></returns>
        protected PageTemplate GetPageModel(CachedEditableModel cachedModel)
        {
            dynamic model = Activator.CreateInstance(cachedModel.ModelType);

            UpdateModel(model);

            return(model as PageTemplate);
        }
Пример #3
0
        public ActionResult ChangePageTemplate(string modelType)
        {
            PageModel model = new PageModel();

            model.ModelType = modelType;

            CachedEditableModel cachedModel = CMSCache.Pages[model.ModelType];

            model.PageTemplateModel = Activator.CreateInstance(cachedModel.ModelType) as PageTemplate;  // new Framework.Models.Page.Default();

            model.PageTemplateModel.DisplayLocation = cachedModel.DisplayLocation;
            model.PageTemplateModel.EditorLocation  = cachedModel.EditorLocation;

            model.PageTemplateModel.InitialiseForEditor();

            return(PartialView("_ChangePageTemplate", model));
        }
Пример #4
0
        public ActionResult PageEdit(PageModel model)
        {
            CachedEditableModel cachedModel = CMSCache.Pages[model.ModelType];

            model.PageTemplateModel = GetPageModel(cachedModel);  //.GetPageModel();
            //UpdateModel( model.PageTemplateModel );

            PageManager manager = new PageManager();

            SaveResult result = manager.SavePage(model);

            if (result.State == SaveResultState.Success)
            {
                return(RedirectToAction("PageList"));
            }

            return(View(model));
        }
Пример #5
0
        public ActionResult HomePageEdit(HomePageModel model)
        {
            CachedEditableModel cachedModel = CMSCache.HomePages[model.HomePageTemplate];

            model.HomePageTemplateModel = GetHomePageModel(cachedModel);

            if (model.HomePageTemplateModel != null)
            {
                HomePageManager manager = new HomePageManager();
                SaveResult      result  = manager.SaveHomePageModel(model);

                if (result.State == SaveResultState.Success)
                {
                    return(Redirect("/admin"));
                }
            }

            return(View(model));
        }
Пример #6
0
        /* ---------------------------------------------------------------------------------------------------------- */

        #region Class Members

        #endregion

        /* ---------------------------------------------------------------------------------------------------------- */

        #region Constructors/Initialisation

        #endregion

        /* ---------------------------------------------------------------------------------------------------------- */

        #region Public Methods

        /// <summary>
        /// Gets the model to use for the admin page model.
        /// </summary>
        public PageModel GetPageModel(int?pageId)
        {
            ContentManagementDb db = new ContentManagementDb();

            Page page = db.Pages.Find(pageId);

            if (page == null)
            {
                PageModel model = new PageModel();

                model.ModelType         = "Default";
                model.PageTemplateModel = new Framework.Models.Page.Default();

                CachedEditableModel cachedModel = CMSCache.Pages[model.ModelType];

                model.PageTemplateModel.DisplayLocation = cachedModel.DisplayLocation;
                model.PageTemplateModel.EditorLocation  = cachedModel.EditorLocation;

                return(model);
            }

            return(new PageModel(page, this));
        }