Beispiel #1
0
        public async Task <PageModuleTypeFileDetails> ExecuteAsync(GetPageModuleTypeFileDetailsByFileNameQuery query, IExecutionContext executionContext)
        {
            var viewPath = _viewLocator.GetPathByFileName(query.FileName);

            if (string.IsNullOrEmpty(viewPath))
            {
                throw new FileNotFoundException($"Page module view file '{query.FileName}' not found.");
            }

            var view = await _viewFileReader.ReadViewFileAsync(viewPath);

            if (view == null)
            {
                throw new FileNotFoundException($"Page module view file '{query.FileName}' not found at location '{viewPath}'.");
            }

            var parsedData           = ParseViewFile(view);
            var pageTemplateFileInfo = new PageModuleTypeFileDetails();

            pageTemplateFileInfo.Name        = StringHelper.FirstNonEmpty(parsedData.Name, TextFormatter.PascalCaseToSentence(query.FileName));
            pageTemplateFileInfo.Description = parsedData.Description;
            pageTemplateFileInfo.Templates   = await MapChildTemplates(query.FileName);

            return(pageTemplateFileInfo);
        }
Beispiel #2
0
        private string GetViewPath(IEntityVersionPageModuleRenderDetails moduleViewModel)
        {
            string viewPath;
            string fileName = moduleViewModel.ModuleType.FileName;

            if (moduleViewModel.Template == null)
            {
                viewPath = _pageModuleTypeViewFileLocator.GetPathByFileName(fileName);
            }
            else
            {
                viewPath = _pageModuleTypeViewFileLocator.GetTemplatePathByTemplateFileName(fileName, moduleViewModel.Template.FileName);
            }

            if (viewPath == null)
            {
                return(null);
            }
            return("~" + viewPath);
        }