Faturas duplicadas não são mais salvas.

Criado endpoint para teste.
This commit is contained in:
Adriano Serighelli 2025-06-10 10:03:45 -03:00
parent 9197d900ff
commit 13c7356d9e
2 changed files with 324 additions and 311 deletions

View File

@ -188,6 +188,9 @@ namespace Webhook_4docs
{
path = fatura.PastaTUSD!.FullName;
}
if (status_id != 4)
{
fatura_arquivo = IndexedFilename($@"{path}\ID {fatura_ID!} - Mês {fatura.Mes} - Empresa {fatura.Empresa} - Unidade {fatura.Unidade}", "pdf");
CriarArquivo(fatura_arquivo, JsonBody.GetProperty("pdfFile").ToString());
@ -201,20 +204,26 @@ namespace Webhook_4docs
logger.LogInformation("Fatura incluída no BD");
logger.LogInformation("Fatura salva na pasta " + fatura_arquivo);
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<WebhookDbContext>();
dbContext.ProcessedInvoices.Add(DatabaseModel);
await dbContext.SaveChangesAsync();
}
}
else
{
logger.LogInformation("Fatura duplicada no BD");
logger.LogInformation("Fatura salva na pasta " + fatura_arquivo);
logger.LogInformation("Fatura descartada");
}
}
catch
{
logger.LogError("Erro no processamento da fatura");
}
}
else if (JsonBody.TryGetProperty("healthy", out _) && JsonBody.TryGetProperty("blame", out _) && JsonBody.TryGetProperty("locationID", out _))
{
@ -247,6 +256,10 @@ namespace Webhook_4docs
}
}
});
endpoints.MapPut("/api", async context =>
{
var a = 10;
});
});
app.Run();
}