public void shouldSuccessDocumentNonPOPDFInklaringTemplateItemMoreThanOne()
        {
            VBRealizationDocumentNonPOPDFInklaringTemplate PdfTemplate = new VBRealizationDocumentNonPOPDFInklaringTemplate();
            MemoryStream result = PdfTemplate.GeneratePdfTemplate(VBRealizationDocumentNonPOPDFInklaringTemplateItemMoreThanOneViewModel, 7);

            Assert.NotNull(result);
        }
        public void shouldSuccessDocumentNonPOPDFInklaringTemplateWithPPNandPPHNull()
        {
            VBRealizationDocumentNonPOPDFInklaringTemplate PdfTemplate = new VBRealizationDocumentNonPOPDFInklaringTemplate();
            MemoryStream result = PdfTemplate.GeneratePdfTemplate(VBRealizationDocumentNonPOPDFInklaringTemplatePPHandPPNNullViewModel, 7);

            Assert.NotNull(result);
        }
Example #3
0
        public async Task <IActionResult> GetPDFNonPO([FromRoute] int id)
        {
            try
            {
                var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");
                int timeoffsset    = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                var data           = await _service.ReadByIdAsync(id);

                if (data == null)
                {
                    Dictionary <string, object> Result =
                        new ResultFormatter(ApiVersion, General.NOT_FOUND_STATUS_CODE, General.NOT_FOUND_MESSAGE)
                        .Fail();
                    return(NotFound(Result));
                }
                else
                {
                    if (data.IsInklaring)
                    {
                        VBRealizationDocumentNonPOPDFInklaringTemplate PdfTemplate = new VBRealizationDocumentNonPOPDFInklaringTemplate();
                        MemoryStream stream = PdfTemplate.GeneratePdfTemplate(data, timeoffsset);
                        return(new FileStreamResult(stream, "application/pdf")
                        {
                            FileDownloadName = $"Realisasi VB Inklaring Tanpa PO - {data.DocumentNo}.pdf"
                        });
                    }
                    else
                    {
                        VBRealizationDocumentNonPOPDFTemplate PdfTemplate = new VBRealizationDocumentNonPOPDFTemplate();
                        MemoryStream stream = PdfTemplate.GeneratePdfTemplate(data, timeoffsset);
                        return(new FileStreamResult(stream, "application/pdf")
                        {
                            FileDownloadName = $"Realisasi VB Tanpa PO - {data.DocumentNo}.pdf"
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }