diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 21fba541..3f498ad9 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -177,8 +177,7 @@ public class DailyReportService : IDailyReportService datesRange.To = finishDate; } - result.Count = (int)(Math.Ceiling((datesRange.To - DateTimeOffset.UnixEpoch).TotalDays) - - Math.Floor((datesRange.From - DateTimeOffset.UnixEpoch).TotalDays)); + result.Count = (datesRange.To.Day - DateTimeOffset.UnixEpoch.Day) - (datesRange.From.Day - DateTimeOffset.UnixEpoch.Day); var existingDailyReports = await dailyReportRepository.GetAsync(idWell, request, cancellationToken); diff --git a/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs b/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs index 38f1959e..90c00957 100644 --- a/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs +++ b/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs @@ -157,7 +157,7 @@ public class DailyReportServiceTest IdParentCategory = 4001, IdWellSectionType = 1, OperationCategoryName = "Механическое. бурение", - DateStart = new DateTime(2023, 10, 26), + DateStart = new DateTime(2023, 10, 26, 0, 0, 0), DepthStart = 80, DepthEnd = 150, DurationHours = 8, @@ -169,7 +169,7 @@ public class DailyReportServiceTest OperationCategoryName = "Механическое. бурение", IdWellSectionType = 1, IdParentCategory = 4001, - DateStart = new DateTime(2023, 10, 26), + DateStart = new DateTime(2023, 10, 26, 23, 59, 59), DepthStart = 150, DepthEnd = 200, DurationHours = 8, @@ -507,7 +507,7 @@ public class DailyReportServiceTest public async Task GetAsync_ShouldReturn_FictiveDailyReport() { //arrange - var expectedCount = (fakeLastFactWellOperation.DateStart - fakeFirstFactWellOperation.DateStart).TotalDays + 1; + var expectedCount = fakeLastFactWellOperation.DateStart.Day - fakeFirstFactWellOperation.DateStart.Day; //act var result = await dailyReportService.GetAsync(idWell, new FileReportRequest(), CancellationToken.None);