diff --git a/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs b/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs index 767cdab..87c25b1 100644 --- a/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs +++ b/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs @@ -26,13 +26,13 @@ public static class CreateConsumption { public Validator(TimeProvider timeProvider) { - DateTime todayEndOfDay = timeProvider.GetUtcNow() + Func getTodayEndOfDay = () => timeProvider.GetUtcNow() .Date .AddDays(1) .AddTicks(-1); - + RuleFor(x => x.DateTime.ToUniversalTime()) - .LessThanOrEqualTo(todayEndOfDay) + .LessThanOrEqualTo(_ => getTodayEndOfDay()) .WithName(nameof(Request.DateTime)); RuleFor(x => x.Distance) diff --git a/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs b/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs index 80ce097..119f1fb 100644 --- a/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs +++ b/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs @@ -26,13 +26,13 @@ public static class UpdateConsumption { public Validator(TimeProvider timeProvider) { - DateTime todayEndOfDay = timeProvider.GetUtcNow() + Func getTodayEndOfDay = () => timeProvider.GetUtcNow() .Date .AddDays(1) .AddTicks(-1); RuleFor(x => x.DateTime.ToUniversalTime()) - .LessThanOrEqualTo(todayEndOfDay) + .LessThanOrEqualTo(_ => getTodayEndOfDay()) .WithName(nameof(Request.DateTime)); RuleFor(x => x.Distance)