public ActionResult RenderDashboard(DashboardItemModel model)
        {
            switch (model.DashboardType)
            {
                case DashboardType.PartialView:
                    return PartialView(model.ViewName);
                case DashboardType.ChildAction:
                    MethodInfo childAction;
                    var editorController = model.GetEditorDashboardAction(BackOfficeRequestContext.RegisteredComponents, out childAction);

                    if (!TypeFinder.IsTypeAssignableFrom<PartialViewResult>(childAction.ReturnType)
                        && !TypeFinder.IsTypeAssignableFrom<ContentResult>(childAction.ReturnType))
                    {
                        throw new InvalidOperationException("ChildAction dashboards should have a return type of " + typeof(PartialViewResult).Name + " or " + typeof(ContentResult).Name);
                    }

                    //proxy the request to the controller                    
                    var result = this.ProxyRequestToController(
                        ControllerExtensions.GetControllerName(editorController.Metadata.ComponentType), 
                        childAction.Name,
                        editorController.Metadata,
                        BackOfficeRequestContext.Application.Settings.RebelPaths.BackOfficePath,
                        "editorId",
                        new Dictionary<string, object>());

                    return Content(result.RenderedOutput);
                default:
                    throw new ArgumentOutOfRangeException();
            }


        }
Exemplo n.º 2
0
        public ActionResult RenderDashboard(DashboardItemModel model)
        {
            switch (model.DashboardType)
            {
            case DashboardType.PartialView:
                return(PartialView(model.ViewName));

            case DashboardType.ChildAction:
                MethodInfo childAction;
                var        editorController = model.GetEditorDashboardAction(BackOfficeRequestContext.RegisteredComponents, out childAction);

                if (!TypeFinder.IsTypeAssignableFrom <PartialViewResult>(childAction.ReturnType))
                {
                    throw new InvalidOperationException("ChildAction dashboards should have a return type of " + typeof(PartialViewResult).Name);
                }

                using (var controller = editorController.Value)
                {
                    if (controller == null)
                    {
                        throw new TypeLoadException("Could not create controller: " + UmbracoController.GetControllerName(editorController.Metadata.ComponentType));
                    }

                    //proxy the request to the controller
                    return(this.ProxyRequestToController(controller, childAction));
                }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
        public ActionResult RenderDashboard(DashboardItemModel model)
        {
            switch (model.DashboardType)
            {
            case DashboardType.PartialView:
                return(PartialView(model.ViewName));

            case DashboardType.ChildAction:
                MethodInfo childAction;
                var        editorController = model.GetEditorDashboardAction(BackOfficeRequestContext.RegisteredComponents, out childAction);

                if (!TypeFinder.IsTypeAssignableFrom <PartialViewResult>(childAction.ReturnType) &&
                    !TypeFinder.IsTypeAssignableFrom <ContentResult>(childAction.ReturnType))
                {
                    throw new InvalidOperationException("ChildAction dashboards should have a return type of " + typeof(PartialViewResult).Name + " or " + typeof(ContentResult).Name);
                }

                //proxy the request to the controller
                var result = this.ProxyRequestToController(
                    ControllerExtensions.GetControllerName(editorController.Metadata.ComponentType),
                    childAction.Name,
                    editorController.Metadata,
                    BackOfficeRequestContext.Application.Settings.RebelPaths.BackOfficePath,
                    "editorId",
                    new Dictionary <string, object>());

                return(Content(result.RenderedOutput));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }