Фикс сортировку операций

This commit is contained in:
Степанов Дмитрий 2024-09-02 18:42:47 +05:00
parent 194df95d28
commit 7d172129e6

View File

@ -161,7 +161,7 @@ public class WellOperationService : IWellOperationService
var groupedByWellAndTypeDtos = wellOperationsBaseDtos var groupedByWellAndTypeDtos = wellOperationsBaseDtos
.GroupBy(e => new { e.IdWell, e.IdType }); .GroupBy(e => new { e.IdWell, e.IdType });
var result = new List<WellOperationDto>(); var wellOperations = new List<WellOperationDto>();
var count = 0; var count = 0;
foreach (var wellOperationsWithTypeDto in groupedByWellAndTypeDtos) foreach (var wellOperationsWithTypeDto in groupedByWellAndTypeDtos)
{ {
@ -179,8 +179,6 @@ public class WellOperationService : IWellOperationService
if (request.Take != null) if (request.Take != null)
filteredWellOperations = filteredWellOperations.Take((int)request.Take); filteredWellOperations = filteredWellOperations.Take((int)request.Take);
var timezoneOffset = wellService.GetTimezone(wellOperationsWithTypeDto.Key.IdWell).Offset;
var dtos = filteredWellOperations var dtos = filteredWellOperations
.Select(dto => .Select(dto =>
{ {
@ -192,8 +190,13 @@ public class WellOperationService : IWellOperationService
return newDto; return newDto;
}); });
result.AddRange(dtos); wellOperations.AddRange(dtos);
} }
var result =
request.SortFields?.Any() is true ?
wellOperations.AsQueryable().SortBy(request.SortFields) :
wellOperations.AsQueryable().OrderBy(e => e.DateStart);
return (result, count); return (result, count);
} }
@ -308,10 +311,6 @@ public class WellOperationService : IWellOperationService
var leDateUtc = request.LeDate.Value.UtcDateTime; var leDateUtc = request.LeDate.Value.UtcDateTime;
dtos = dtos.Where(e => e.DateStart <= leDateUtc); dtos = dtos.Where(e => e.DateStart <= leDateUtc);
} }
if (request.SortFields?.Any() is true)
dtos = dtos.AsQueryable().SortBy(request.SortFields);
else
dtos = dtos.AsQueryable().OrderBy(e => e.DateStart);
return dtos; return dtos;
} }