BetterCms.Module.Root.Controllers.PreviewController.Index C# (CSharp) Method

Index() private method

private Index ( string pageId, string pageContentId ) : System.Web.Mvc.ActionResult
pageId string
pageContentId string
return System.Web.Mvc.ActionResult
        public ActionResult Index(string pageId, string pageContentId)
        {
            var principal = SecurityService.GetCurrentPrincipal();

            var allRoles = new List<string>(RootModuleConstants.UserRoles.AllRoles);
            if (!string.IsNullOrEmpty(cmsConfiguration.Security.FullAccessRoles))
            {
                allRoles.Add(cmsConfiguration.Security.FullAccessRoles);
            }

            var request = new GetPageToRenderRequest
                {
                    PageId = pageId.ToGuidOrDefault(),
                    PreviewPageContentId = pageContentId.ToGuidOrDefault(),
                    IsPreview = true,
                    HasContentAccess = SecurityService.IsAuthorized(principal, RootModuleConstants.UserRoles.MultipleRoles(allRoles.ToArray()))
                };

            var model = GetCommand<GetPageToRenderCommand>().ExecuteCommand(request);

            if (model != null && model.RenderPage != null)
            {
                // Render page with hierarchical master pages
                var html = this.RenderPageToString(model.RenderPage);
                html = PageHtmlRenderer.ReplaceRegionRepresentationHtml(html, string.Empty);

                return Content(html);
            }

            return HttpNotFound();
        }
    }