diff --git a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs index 17665e8c..750e99db 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs @@ -161,7 +161,7 @@ public class WellOperationService : IWellOperationService var groupedByWellAndTypeDtos = wellOperationsBaseDtos .GroupBy(e => new { e.IdWell, e.IdType }); - var result = new List(); + var wellOperations = new List(); var count = 0; foreach (var wellOperationsWithTypeDto in groupedByWellAndTypeDtos) { @@ -179,8 +179,6 @@ public class WellOperationService : IWellOperationService if (request.Take != null) filteredWellOperations = filteredWellOperations.Take((int)request.Take); - var timezoneOffset = wellService.GetTimezone(wellOperationsWithTypeDto.Key.IdWell).Offset; - var dtos = filteredWellOperations .Select(dto => { @@ -192,8 +190,13 @@ public class WellOperationService : IWellOperationService 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); } @@ -308,10 +311,6 @@ public class WellOperationService : IWellOperationService var leDateUtc = request.LeDate.Value.UtcDateTime; 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; }