Code clean up
This commit is contained in:
@@ -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")
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user