Exemplo n.º 1
0
        public async Task <IActionResult> GetPdf(int year, int month, int accountingBookId, string accountingBookType, bool valas)
        {
            try
            {
                var    indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");
                int    timeOffset     = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                string date           = new DateTime(year, month, 1).ToString("MMMM yyyy", new CultureInfo("id-ID"));

                var report = _service.GetReportPdfData(year, month, accountingBookId, accountingBookType, valas);
                if (report.Count <= 0)
                {
                    Dictionary <string, object> Result =
                        new ResultFormatter(ApiVersion, General.NOT_FOUND_STATUS_CODE, General.NOT_FOUND_MESSAGE)
                        .Fail();
                    return(NotFound(Result));
                }

                MemoryStream stream = MemoGarmentPurchasingReportPdfTemplate.GeneratePdfTemplate(report.Data, date, accountingBookType);
                return(new FileStreamResult(stream, "application/pdf")
                {
                    FileDownloadName = $"Laporan Data Memorail - {date}.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));
            }
        }
Exemplo n.º 2
0
        public void shouldSuccessDocumentNonPOPDFInklaringTemplateItemMoreThanOne()
        {
            List <MemoGarmentPurchasingModel> model = new List <MemoGarmentPurchasingModel>();

            model.Add(MemoGarmentPurchasingViewModel);
            MemoryStream result = MemoGarmentPurchasingReportPdfTemplate.GeneratePdfTemplate(model, "", "Test");

            Assert.NotNull(result);
        }