diff --git a/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs b/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs index 0ab43cd..2b293a1 100644 --- a/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs +++ b/SteUp.Data/LocalDb/EntityServices/IspezioniService.cs @@ -18,13 +18,15 @@ public class IspezioniService(AppDbContext db) : IIspezioniService x.Data == data && x.Rilevatore == rilevatore); - public Task> GetAllIspezioni() => + public Task> GetAllIspezioni(string rilevatore) => db.Ispezioni + .Where(x => x.Rilevatore.Equals(rilevatore, StringComparison.InvariantCultureIgnoreCase)) .AsNoTracking() .ToListAsync(); - public Task> GetAllIspezioniWithSchedeAsync() => + public Task> GetAllIspezioniWithSchedeAsync(string rilevatore) => db.Ispezioni + .Where(x => x.Rilevatore.Equals(rilevatore, StringComparison.InvariantCultureIgnoreCase)) .Include(x => x.Schede) .ThenInclude(s => s.Articoli) .AsNoTracking() diff --git a/SteUp.Shared/Components/Pages/IspezioniPage.razor b/SteUp.Shared/Components/Pages/IspezioniPage.razor index cb8d403..3dbc4c8 100644 --- a/SteUp.Shared/Components/Pages/IspezioniPage.razor +++ b/SteUp.Shared/Components/Pages/IspezioniPage.razor @@ -41,7 +41,7 @@ private async Task LoadData() { - Ispezioni = await IspezioniService.GetAllIspezioniWithSchedeAsync(); + Ispezioni = await IspezioniService.GetAllIspezioniWithSchedeAsync(UserSession.User.Username); } private void OnClickIspezione(Ispezione ispezione) diff --git a/SteUp.Shared/Core/Data/SteupDataService.cs b/SteUp.Shared/Core/Data/SteupDataService.cs index 66d7cc0..c5bd86d 100644 --- a/SteUp.Shared/Core/Data/SteupDataService.cs +++ b/SteUp.Shared/Core/Data/SteupDataService.cs @@ -38,7 +38,7 @@ public class SteupDataService( private async Task CleanOldClosedInspection() { - var ispezioni = (await ispezioniService.GetAllIspezioniWithSchedeAsync()) + var ispezioni = (await ispezioniService.GetAllIspezioniWithSchedeAsync(userSession.User.Username)) .Where(x => x.Stato == StatusEnum.Completata && x.Data < DateTime.Now.AddDays(-60) @@ -53,7 +53,7 @@ public class SteupDataService( public async Task CheckAndUpdateStatus() { - var ispezioni = await ispezioniService.GetAllIspezioniWithSchedeAsync(); + var ispezioni = await ispezioniService.GetAllIspezioniWithSchedeAsync(userSession.User.Username); var listActivityId = ispezioni .Where(x => x.ActivityId != null) .Select(x => x.ActivityId!) @@ -95,7 +95,7 @@ public class SteupDataService( public async Task CanOpenNewInspection() { - var completedInspection = await ispezioniService.GetAllIspezioni(); + var completedInspection = await ispezioniService.GetAllIspezioni(userSession.User.Username); if (completedInspection.IsNullOrEmpty()) return true; diff --git a/SteUp.Shared/Core/Interface/LocalDb/IIspezioniService.cs b/SteUp.Shared/Core/Interface/LocalDb/IIspezioniService.cs index c7d30cc..d9d856f 100644 --- a/SteUp.Shared/Core/Interface/LocalDb/IIspezioniService.cs +++ b/SteUp.Shared/Core/Interface/LocalDb/IIspezioniService.cs @@ -8,8 +8,8 @@ public interface IIspezioniService { // ISPEZIONI Task GetIspezioneAsync(string codMdep, DateTime data, string rilevatore); - Task> GetAllIspezioni(); - Task> GetAllIspezioniWithSchedeAsync(); + Task> GetAllIspezioni(string rilevatore); + Task> GetAllIspezioniWithSchedeAsync(string rilevatore); Task AddIspezioneAsync(Ispezione ispezione); Task GetOrCreateIspezioneAsync(string codMdep, DateTime data, string rilevatore); Task UpdateIspezioneAsync(Ispezione ispezione);