Inheritance: IModelBindAware
Exemplo n.º 1
0
        public ActionResult SetParameters(HiveId contentId, string macroAlias, bool isNew, string inlineMacroId = "", string macroParameters = "")
        {
            var viewModel = new SetParametersModel
            {
                ContentId = contentId,
                IsNew = isNew,
                InlineMacroId = inlineMacroId
            };

            var macroEditorModel = GetMacroByAlias(macroAlias);

            BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map
                <MacroEditorModel, SetParametersModel>(macroEditorModel, viewModel);

            if (!string.IsNullOrEmpty(macroParameters))
            {
                var macroParamsDict = macroParameters.DecodeMacroParameters();

                foreach (var macroParam in viewModel.MacroParameters.Where(macroParam => macroParamsDict.ContainsKey(macroParam.Alias)))
                {
                    macroParam.ParameterEditorModel.SetModelValue(macroParamsDict[macroParam.Alias]);
                }
            }

            //return View(EmbeddedViewEngine.EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.Views.InsertMacroDialog.cshtml", "Rebel.Cms.Web.PropertyEditors"));
            return View(EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMacro.SetParameters.cshtml, Rebel.Cms.Web.PropertyEditors"), viewModel);
        }
        public ActionResult SetParameters(string macroAlias)
        {
            var viewModel = new SetParametersModel();

            var macroEditorModel = GetMacroByAlias(macroAlias);

            if(macroEditorModel.MacroParameters.Count == 0)
            {
                return RedirectToAction("InsertMacro", new { macroAlias });
            }

            BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map
                <MacroEditorModel, SetParametersModel>(macroEditorModel, viewModel);

            return View(viewModel);
        }
        public ActionResult InsertMacro(string macroAlias)
        {
            // Create the view model
            var setParamsViewModel = new SetParametersModel();

            // Populate view model with default content from macro definition
            var macroEditorModel = GetMacroByAlias(macroAlias);
            BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map
                <MacroEditorModel, SetParametersModel>(macroEditorModel, setParamsViewModel);

            // Bind the post data back to the view model
            setParamsViewModel.BindModel(this);

            // Convert model
            var insertMacroViewModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map
                <SetParametersModel, InsertMacroModel>(setParamsViewModel);

            return View(insertMacroViewModel);
        }
Exemplo n.º 4
0
        public ActionResult SetParametersForm(HiveId contentId, string macroAlias, bool isNew, string inlineMacroId = "")
        {
            // Create the view model
            var setParamsViewModel = new SetParametersModel
            {
                ContentId = contentId,
                IsNew = isNew,
                InlineMacroId = inlineMacroId
            };

            // Populate view model with default content from macro definition
            var macroEditorModel = GetMacroByAlias(macroAlias);
            BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map
                <MacroEditorModel, SetParametersModel>(macroEditorModel, setParamsViewModel);

            // Bind the post data back to the view model
            setParamsViewModel.BindModel(this);

            // Convert model
            var insertMacroViewModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map
                <SetParametersModel, InsertMacroModel>(setParamsViewModel);

            return View(EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMacro.InsertMacro.cshtml, Rebel.Cms.Web.PropertyEditors"), insertMacroViewModel);
        }