/// <summary>
        /// Преглед на бланка
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Preview(int id)
        {
            if (id == 0)
            {
                return(null);
            }
            ViewBag.breadcrumbs = commonService.Breadcrumbs_HtmlTemplatePreview(id).DeleteOrDisableLast();

            var model     = service.GetById <HtmlTemplate>(id);
            var htmlModel = printDocumentService.ConvertToTinyMCVM(model, model.HaveSessionAct == true);

            ViewBag.PreviewTitle = model.Label;
            return(View("Preview", htmlModel));
        }
Exemplo n.º 2
0
        private async Task <BlankEditVM> InitBlankFromTemplate(int id, bool del)
        {
            var docTemplate = service.GetById <DocumentTemplate>(id);
            int sourceType  = SourceTypeSelectVM.DocumentTemplate;

            if (del)
            {
                var deleted = await cdnService.MongoCdn_DeleteFiles(new CdnFileSelect()
                {
                    SourceType = sourceType, SourceId = id.ToString()
                });
            }
            string html = await cdnService.LoadHtmlFileTemplate(new CdnFileSelect()
            {
                SourceType = sourceType, SourceId = id.ToString()
            });

            if (string.IsNullOrEmpty(html))
            {
                TinyMCEVM htmlModel = printService.FillHtmlTemplateDocumentTemplate(id);
                html = htmlModel.Text;
            }

            var model = new BlankEditVM()
            {
                Title            = "Изготвяне на документ към " + SourceTypeSelectVM.GetSourceTypeName(sourceType).ToLower(),
                SourceType       = sourceType,
                SourceId         = id.ToString(),
                HtmlHeader       = string.Empty,
                HtmlContent      = html,
                HtmlFooter       = string.Empty,
                FooterIsEditable = false,
                ReturnUrl        = Url.Action(nameof(Edit), new { id }),
                HasPreviewButton = true,
                HasResetButton   = true,
            };

            if (docTemplate.HtmlTemplateId > 0)
            {
                var htmlTemplate = service.GetById <HtmlTemplate>(docTemplate.HtmlTemplateId);
                var htmlModel    = printService.ConvertToTinyMCVM(htmlTemplate, false);
                model.TemplateStyle = htmlModel.Style;
            }
            return(model);
        }