diff --git a/Yavsc/ApiControllers/BillingController.cs b/Yavsc/ApiControllers/BillingController.cs index 0de4bdc0..fd252263 100644 --- a/Yavsc/ApiControllers/BillingController.cs +++ b/Yavsc/ApiControllers/BillingController.cs @@ -64,11 +64,9 @@ namespace Yavsc.ApiControllers return new ChallengeResult(); } - var filename = $"facture-{billingCode}-{id}.pdf"; - - FileInfo fi = new FileInfo(Path.Combine(Startup.UserBillsDirName, filename)); + var fi = BillingHelpers.GetBillInfo(billingCode,id); if (!fi.Exists) return Ok(new { Error = "Not generated" }); - return File(fi.OpenRead(), "application/x-pdf", filename); ; + return File(fi.OpenRead(), "application/x-pdf", fi.Name); } [HttpGet("facture-{billingCode}-{id}.tex"), Authorize] diff --git a/Yavsc/Helpers/BillingHelpers.cs b/Yavsc/Helpers/BillingHelpers.cs index bbc47dc7..67657fbd 100644 --- a/Yavsc/Helpers/BillingHelpers.cs +++ b/Yavsc/Helpers/BillingHelpers.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; using Yavsc.Billing; using Yavsc.Models.Billing; @@ -18,5 +19,11 @@ namespace Yavsc.Helpers $"\n\nTotal: {total}"; return bill; } + + public static FileInfo GetBillInfo(string billingcode, long id) + { + var filename = $"facture-{billingcode}-{id}.pdf"; + return new FileInfo(Path.Combine(Startup.UserBillsDirName, filename)); + } } } diff --git a/Yavsc/Views/Shared/Components/Bill/Default.cshtml b/Yavsc/Views/Shared/Components/Bill/Default.cshtml index 7270452c..c56e66ee 100644 --- a/Yavsc/Views/Shared/Components/Bill/Default.cshtml +++ b/Yavsc/Views/Shared/Components/Bill/Default.cshtml @@ -1,13 +1,12 @@ @model IBillable
- -Export au format LaTeX - - +@{ var fi = BillingHelpers.GetBillInfo(ViewBag.BillingCode,Model.Id); } +@if (fi.Exists) { +La facture au format Pdf +} else {
- +
- -Télécharger le document généré +}
diff --git a/Yavsc/Yavsc.csproj b/Yavsc/Yavsc.csproj index edfe004d..0273a7cf 100644 --- a/Yavsc/Yavsc.csproj +++ b/Yavsc/Yavsc.csproj @@ -1199,6 +1199,9 @@ + + +