示例#1
0
        public ViewResult Create(string id, string session, int?contentId = null, string contentType = null)
        {
            var sessionState = new ElementSessionState {
                TypeName    = id,
                ElementData = null,
                ContentId   = contentId,
                ContentType = contentType
            };

            _objectStore.Set(session, sessionState);

            var describeContext = CreateDescribeContext(contentId, contentType);
            var descriptor      = _elementManager.GetElementDescriptorByTypeName(describeContext, id);
            var element         = _elementManager.ActivateElement(descriptor);
            var context         = CreateEditorContext(session, describeContext.Content, element);
            var editorResult    = _elementManager.BuildEditor(context);
            var viewModel       = new EditElementViewModel {
                SessionKey   = session,
                Layout       = describeContext.Content.As <ILayoutAspect>(),
                EditorResult = editorResult,
                TypeName     = id,
                DisplayText  = descriptor.DisplayText,
                ElementData  = element.Data.Serialize(),
                Submitted    = !descriptor.EnableEditorDialog,
                ElementHtml  = RenderElement(element, describeContext),
                Tabs         = editorResult.CollectTabs().ToArray()
            };

            return(View(viewModel));
        }
示例#2
0
        public RedirectToRouteResult Add(string session, string typeName, int?contentId = null, string contentType = null)
        {
            var state = new ElementSessionState {
                TypeName    = typeName,
                ContentId   = contentId,
                ContentType = contentType
            };

            _objectStore.Set(session, state);
            return(RedirectToAction("Edit", new { session = session }));
        }