diff --git a/AsbCloudInfrastructure/Services/AutoGeneratedDailyReports/AutoGeneratedDailyReportService.cs b/AsbCloudInfrastructure/Services/AutoGeneratedDailyReports/AutoGeneratedDailyReportService.cs index edf3641b..03a19c44 100644 --- a/AsbCloudInfrastructure/Services/AutoGeneratedDailyReports/AutoGeneratedDailyReportService.cs +++ b/AsbCloudInfrastructure/Services/AutoGeneratedDailyReports/AutoGeneratedDailyReportService.cs @@ -149,8 +149,8 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService return new DatesRangeDto { - From = factOperations.First().DateStart, - To = factOperations.Last().DateStart + From = factOperations.Min(o => o.DateStart), + To = factOperations.Max(o => o.DateStart) }; } @@ -209,7 +209,7 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService }); } - private Task> GetFactOperationsAsync(int idWell, DateTime? startDate, + private async Task> GetFactOperationsAsync(int idWell, DateTime? startDate, DateTime? finishDate, CancellationToken cancellationToken) { var request = new WellOperationRequest @@ -221,7 +221,8 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService SortFields = new[] { "DateStart asc" }, }; - return wellOperationRepository.GetAsync(request, cancellationToken); + return (await wellOperationRepository.GetAsync(request, cancellationToken)) + .OrderBy(w => w.DateStart); } private Task?> GetSubsystemStatsAsync(int idWell, DateTime startDate,