public async Task <IActionResult> Preview(int headerId, int languageId)
        {
            try
            {
                var page = await _pageService.GetByHeaderAndLanguageAsync(headerId, languageId);

                var language = await _languageService.GetActiveByIdAsync(languageId);

                PageTitle = $"Preview - {page.Title}";

                var viewModel = new PagePreviewViewModel
                {
                    HeaderId = headerId,
                    Language = language.Name,
                    Content  = CommonMark.CommonMarkConverter.Convert(page.Content),
                    Stub     = page.PageStub
                };
                return(View(viewModel));
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to view page: ", gex);
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Preview(string stub)
        {
            try
            {
                var page = await _pageService.GetByStubAsync(stub, false);

                PageTitle = $"Preview - {page.Title}";

                PagePreviewViewModel viewModel = new PagePreviewViewModel()
                {
                    Content = CommonMark.CommonMarkConverter.Convert(page.Content),
                    Stub    = stub
                };
                return(View(viewModel));
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to view page: ", gex);
                return(RedirectToAction("Index"));
            }
        }