Exemplo n.º 1
0
        public static void ValidateContent(this CreateTemplateVersionRequest request)
        {
            TemplateContentDomain content = request.Content;

            if (content.Type != Common.Enumerations.TemplateType.Table &&
                content.Type != Common.Enumerations.TemplateType.Text)
            {
                throw new NsiArgumentException(TemplateManagementMessages.InvalidTemplateType,
                                               Common.Enumerations.SeverityEnum.Warning);
            }
            if (content.Payload.Text == null && content.Type == Common.Enumerations.TemplateType.Text)
            {
                throw new NsiArgumentException(TemplateManagementMessages.InvalidTemplatePayload,
                                               Common.Enumerations.SeverityEnum.Warning);
            }
        }
Exemplo n.º 2
0
 public byte[] GeneratePdfFromTemplate(string content, string name)
 {
     try
     {
         TemplateContentDomain templateContentDomain = JObject.Parse(content).ToObject <TemplateContentDomain>();
         if (templateContentDomain.Type == Common.Enumerations.TemplateType.Text)
         {
             return(_pdfGenerator.GenerateTextTemplatePdf(templateContentDomain.Payload, name));
         }
         else
         {
             return(_pdfGenerator.GenerateTableTemplatePdf(templateContentDomain.Payload, name));
         }
     }
     catch (Exception e)
     {
         throw new NsiBaseException(DocumentMessages.PDFGeneratorFailed, e, Common.Enumerations.SeverityEnum.Error);
     }
 }