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));
}