Merge pull request 'Фикс сортировки операций' (#316) from fix/sorting into dev

Reviewed-on: https://test.digitaldrilling.ru:8443/DDrilling/AsbCloudServer/pulls/316
This commit is contained in:
Никита Фролов 2024-09-03 13:34:41 +05:00
commit c833bb2a55

View File

@ -161,7 +161,7 @@ public class WellOperationService : IWellOperationService
var groupedByWellAndTypeDtos = wellOperationsBaseDtos
.GroupBy(e => new { e.IdWell, e.IdType });
var result = new List<WellOperationDto>();
var wellOperations = new List<WellOperationDto>();
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,9 +190,14 @@ 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;
}