From e524c12a96f528603bede47432622d4a43aa136f Mon Sep 17 00:00:00 2001 From: MarcoE Date: Tue, 29 Sep 2026 10:33:01 +0200 Subject: [PATCH] Riporta a bozza le schede non inviate senza reparto o motivo Co-Authored-By: Claude Opus 5.5 (1M context) --- .../EntityServices/IspezioniService.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs b/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs index cf3a1be..5a9a4b5 100644 --- a/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs +++ b/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs @@ -155,14 +155,29 @@ public class IspezioniService(AppDbContext db) : IIspezioniService await db.SaveChangesAsync(); } - public Task> GetAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore) => - db.Schede + public async Task> GetAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore) + { + // Le versioni precedenti dell'app hanno lasciato schede non bozza senza + // reparto o motivo: risultano inviabili ma il server le rifiuta, e + // bloccano la conclusione dell'ispezione. Tornano bozze, cosi' il + // rilevatore le completa. Quelle gia' inviate non si toccano. + await db.Schede + .Where(x => x.CodMdep == codMdep && + x.Data == data && + x.Rilevatore == rilevatore && + !x.Bozza && + x.ActivityId == null && + (string.IsNullOrEmpty(x.CodJfas) || string.IsNullOrEmpty(x.ActivityTypeId))) + .ExecuteUpdateAsync(s => s.SetProperty(x => x.Bozza, true)); + + return await db.Schede .AsNoTracking() .Include(s => s.Articoli) .Where(x => x.CodMdep == codMdep && x.Data == data && x.Rilevatore == rilevatore) .ToListAsync(); + } public Task GetSchedaAsync(int schedaId) => db.Schede