public async Task <IActionResult> GetPDFById([FromRoute] int id) { try { VerifyUser(); var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf"); int timeoffsset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var result = await _service.GetPDFByIdAsync(id); if (result == null) { Dictionary <string, object> Result = new ResultFormatter(_apiVersion, General.NOT_FOUND_STATUS_CODE, General.NOT_FOUND_MESSAGE) .Fail(); return(NotFound(Result)); } else { OthersExpenditureDocumentPDFTemplate PdfTemplate = new OthersExpenditureDocumentPDFTemplate(); MemoryStream stream = PdfTemplate.GeneratePdfTemplate(result, timeoffsset); return(new FileStreamResult(stream, "application/pdf") { FileDownloadName = $"Bukti Pengeluaran Bank (Lain-lain) - {result.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)); } }
public void shouldSuccessPDFTemplateWithCurrencyNonIDR() { OthersExpenditureDocumentPDFTemplate PdfTemplate = new OthersExpenditureDocumentPDFTemplate(); MemoryStream result = PdfTemplate.GeneratePdfTemplate(othersExpenditureProofDocumentPDFViewModelNonIDR, 7); Assert.NotNull(result); }