From 6439bba779474bde98b51860ef4d391823c13a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Wed, 13 Oct 2021 15:45:24 +0500 Subject: [PATCH] Fix WellOperationsStatService.GetStatClusterAsync() Add empty stat for wells with no operations --- .../WellOperationsStatService.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationsStatService.cs index f0082f32..6989d7a4 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationsStatService.cs @@ -70,7 +70,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var wells = await db.Wells .Include(w => w.WellOperations) .Where(w => idWells.Contains(w.Id)) - .Where(w => w.WellOperations.Any()) .AsNoTracking() .ToListAsync(token); @@ -98,10 +97,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService private async Task CalcStatWellAsync(Well well, CancellationToken token = default) { - var wellOperations = well.WellOperations - .OrderBy(o => o.DateStart) - .ThenBy(o => o.DepthEnd); - var wellType = await cacheWellType.FirstOrDefaultAsync(t => t.Id == well.IdWellType, token); var statWellDto = new StatWellDto() @@ -111,6 +106,13 @@ namespace AsbCloudInfrastructure.Services.WellOperationService WellType = wellType.Caption }; + if (well.WellOperations is null) + return statWellDto; + + var wellOperations = well.WellOperations + .OrderBy(o => o.DateStart) + .ThenBy(o => o.DepthEnd); + if (!wellOperations.Any()) return statWellDto;