refactoring
This commit is contained in:
parent
a120dae977
commit
e4ee206c34
3 changed files with 18 additions and 4 deletions
|
|
@ -19,8 +19,8 @@ namespace Yavsc.ApiControllers
|
||||||
|
|
||||||
using Models.Messaging;
|
using Models.Messaging;
|
||||||
using ViewModels.Auth;
|
using ViewModels.Auth;
|
||||||
using Yavsc.ViewComponents;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Yavsc.ViewModels;
|
||||||
|
|
||||||
[Route("api/bill"), Authorize]
|
[Route("api/bill"), Authorize]
|
||||||
public class BillingController : Controller
|
public class BillingController : Controller
|
||||||
|
|
@ -54,7 +54,7 @@ namespace Yavsc.ApiControllers
|
||||||
this.billingService=billingService;
|
this.billingService=billingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("pdf/facture-{billingCode}-{id}.pdf"), Authorize]
|
[HttpGet("facture-{billingCode}-{id}.pdf"), Authorize]
|
||||||
public async Task<IActionResult> GetPdf(string billingCode, long id)
|
public async Task<IActionResult> GetPdf(string billingCode, long id)
|
||||||
{
|
{
|
||||||
var bill = await billingService.GetBillAsync(billingCode, id);
|
var bill = await billingService.GetBillAsync(billingCode, id);
|
||||||
|
|
@ -71,12 +71,16 @@ namespace Yavsc.ApiControllers
|
||||||
return File(fi.OpenRead(), "application/x-pdf", filename); ;
|
return File(fi.OpenRead(), "application/x-pdf", filename); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("tex/{billingCode}-{id}.tex"), Authorize]
|
[HttpGet("facture-{billingCode}-{id}.tex"), Authorize]
|
||||||
public async Task<IActionResult> GetTex(string billingCode, long id)
|
public async Task<IActionResult> GetTex(string billingCode, long id)
|
||||||
{
|
{
|
||||||
|
logger.LogWarning ( $"################################\n# Searching for bill {id} in {billingCode}");
|
||||||
var bill = await billingService.GetBillAsync(billingCode, id);
|
var bill = await billingService.GetBillAsync(billingCode, id);
|
||||||
|
|
||||||
if (bill==null) return this.HttpNotFound();
|
if (bill==null) {
|
||||||
|
logger.LogCritical ( $"# not found !! ##########\n################################");
|
||||||
|
return this.HttpNotFound();
|
||||||
|
}
|
||||||
logger.LogVerbose(JsonConvert.SerializeObject(bill));
|
logger.LogVerbose(JsonConvert.SerializeObject(bill));
|
||||||
|
|
||||||
if (!await authorizationService.AuthorizeAsync(User, bill, new ViewRequirement()))
|
if (!await authorizationService.AuthorizeAsync(User, bill, new ViewRequirement()))
|
||||||
|
|
|
||||||
9
Yavsc/ViewModels/OutputFormat.cs
Normal file
9
Yavsc/ViewModels/OutputFormat.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Yavsc.ViewModels
|
||||||
|
{
|
||||||
|
public enum OutputFormat {
|
||||||
|
Html,
|
||||||
|
LaTeX,
|
||||||
|
Pdf
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
@using Yavsc.Models.Calendar;
|
@using Yavsc.Models.Calendar;
|
||||||
@using Yavsc.Billing;
|
@using Yavsc.Billing;
|
||||||
|
|
||||||
|
@using Yavsc.ViewModels;
|
||||||
@using Yavsc.ViewModels.Account;
|
@using Yavsc.ViewModels.Account;
|
||||||
@using Yavsc.ViewModels.Manage;
|
@using Yavsc.ViewModels.Manage;
|
||||||
@using Yavsc.ViewModels.Calendar;
|
@using Yavsc.ViewModels.Calendar;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue