añado el Controller y metodo para comprobar desde el servicio si existe x documento
This commit is contained in:
parent
0e7bee7e43
commit
6bac2c63fb
|
|
@ -0,0 +1,27 @@
|
|||
using DoliMiddlewareApi.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DoliMiddlewareApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class DocumentController(DocumentService documentService) : ControllerBase
|
||||
{
|
||||
|
||||
[HttpPut("invoice/{invoiceRef}/build")]
|
||||
public async Task<IActionResult> BuildInvoicePdf(string invoiceRef)
|
||||
{
|
||||
await documentService.BuildInvoicePdfAsync(invoiceRef);
|
||||
|
||||
var exists = await documentService.ExistsAsync(invoiceRef);
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
generated = exists,
|
||||
invoiceRef
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,17 @@ namespace DoliMiddlewareApi.Services
|
|||
|
||||
await apiClient.PutAsync("documents/builddoc",request);
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> ExistsAsync(string invoiceRef)
|
||||
{
|
||||
var file = $"¨{invoiceRef}/{invoiceRef}.pdf";
|
||||
|
||||
var endpoint = $"documents?modulepart=invoice&id={invoiceRef}";
|
||||
|
||||
var docs = await apiClient.GetCollectionAsync<string>(endpoint);
|
||||
|
||||
return docs.Contains(file);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue