Code clean up

This commit is contained in:
retr0volkov
2025-07-10 09:19:06 +03:00 Unverified
parent 2a8f8d2714
commit 915c7a7c5e
36 changed files with 116 additions and 133 deletions
+3 -3
View File
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using GazpromApp.Enums;
using GazpromApp.Models;
using GazpromApp.ViewModels;
namespace GazpromApp.Utils;
@@ -19,11 +18,11 @@ public static class DateCalculator
return [inspection.InspectionDate.DateTime, firstFutureDate];
}
DateTime futureDate = Enumerable.Range(1, int.MaxValue)
var futureDate = Enumerable.Range(1, int.MaxValue)
.Select(i => AddPeriod(inspection.InspectionDate.DateTime, inspection.PeriodType, inspection.PeriodValue * i))
.First(d => d > today);
DateTime pastDate = SubtractPeriod(futureDate, inspection.PeriodType, inspection.PeriodValue);
var pastDate = SubtractPeriod(futureDate, inspection.PeriodType, inspection.PeriodValue);
return [pastDate, futureDate];
}
@@ -36,6 +35,7 @@ public static class DateCalculator
PeriodType.Week => date.AddDays(value * 7),
PeriodType.Month => date.AddDays(value * 30.436875), // Avg days/month
PeriodType.Year => date.AddDays(value * 365.2425), // Avg days/year (incl. leap years)
PeriodType.Unknown => throw new ArgumentException("Invalid period type"),
_ => throw new ArgumentException("Invalid period type")
};
}