Bloom.web.controllers.PageTemplatesApi.HandleTemplatesRequest C# (CSharp) Method

HandleTemplatesRequest() public method

Returns a json string for initializing the AddPage dialog. It gives paths to our current TemplateBook and specifies whether the dialog is to be used for adding pages or choosing a different layout.
public HandleTemplatesRequest ( ApiRequest request ) : void
request Bloom.Api.ApiRequest
return void
        public void HandleTemplatesRequest(ApiRequest request)
        {
            dynamic addPageSettings = new ExpandoObject();
            addPageSettings.defaultPageToSelect = _templateInsertionCommand.MostRecentInsertedTemplatePage == null ? "" : _templateInsertionCommand.MostRecentInsertedTemplatePage.Id;
            addPageSettings.orientation = _bookSelection.CurrentSelection.GetLayout().SizeAndOrientation.IsLandScape ? "landscape" : "portrait";

            addPageSettings.groups = GetBookTemplatePaths(GetPathToCurrentTemplateHtml(), _sourceCollectionsList.GetSourceBookPaths())
                .Select(bookTemplatePath => GetPageGroup(bookTemplatePath));
            addPageSettings.currentLayout = _pageSelection.CurrentSelection.IdOfFirstAncestor;

            request.ReplyWithJson(JsonConvert.SerializeObject(addPageSettings));
        }