aggunta transazione

This commit is contained in:
Samuele Locatelli
2026-04-30 08:37:00 +02:00
parent 3e9d0237aa
commit 081a8fcb69
+3
View File
@@ -135,6 +135,7 @@ namespace MP.Data.Controllers
public async Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet)
{
await using var dbCtx = new MoonProContext(_configuration);
await using var tx = await dbCtx.Database.BeginTransactionAsync();
try
{
@@ -195,10 +196,12 @@ namespace MP.Data.Controllers
}
// Nessuna eccezione = successo
await tx.CommitAsync();
return true;
}
catch (Exception ex)
{
await tx.RollbackAsync();
// Log dettagliato errore
Log.Error(ex, $"Errore in CheckCambiaStatoBatchAsync: {IdxMacchina} | {tipoInput}");
throw; // O return false; se il chiamante gestisce fallimenti