From 2e389b252c84081ffed6df5c2acfca3217e714ab Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Mon, 10 Jun 2024 22:03:48 +0300 Subject: [PATCH] refactor: use default pairPeriod --- .../Configuration/ScheduleConfigurationRequest.cs | 10 +--------- Endpoint/Controllers/Configuration/SetupController.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ApiDto/Requests/Configuration/ScheduleConfigurationRequest.cs b/ApiDto/Requests/Configuration/ScheduleConfigurationRequest.cs index ca6e950..b24f529 100644 --- a/ApiDto/Requests/Configuration/ScheduleConfigurationRequest.cs +++ b/ApiDto/Requests/Configuration/ScheduleConfigurationRequest.cs @@ -1,6 +1,4 @@ -using Mirea.Api.Dto.Common; -using System; -using System.Collections.Generic; +using System; using System.ComponentModel.DataAnnotations; namespace Mirea.Api.Dto.Requests.Configuration; @@ -20,10 +18,4 @@ public class ScheduleConfigurationRequest /// [Required] public DateOnly StartTerm { get; set; } - - /// - /// Gets or sets the pair period times, keyed by pair number. - /// - [Required] - public required IDictionary PairPeriod { get; set; } } \ No newline at end of file diff --git a/Endpoint/Controllers/Configuration/SetupController.cs b/Endpoint/Controllers/Configuration/SetupController.cs index 9bda318..2ccac21 100644 --- a/Endpoint/Controllers/Configuration/SetupController.cs +++ b/Endpoint/Controllers/Configuration/SetupController.cs @@ -294,7 +294,16 @@ public class SetupController( // every 6 hours CronUpdateSchedule = request.CronUpdateSchedule ?? "0 */6 * * *", StartTerm = request.StartTerm, - PairPeriod = request.PairPeriod.ConvertFromDto() + PairPeriod = new Dictionary + { + {1, new ScheduleSettings.PairPeriodTime(new TimeOnly(9, 0, 0), new TimeOnly(10, 30, 0))}, + {2, new ScheduleSettings.PairPeriodTime(new TimeOnly(10, 40, 0), new TimeOnly(12, 10, 0))}, + {3, new ScheduleSettings.PairPeriodTime(new TimeOnly(12, 40, 0), new TimeOnly(14, 10, 0))}, + {4, new ScheduleSettings.PairPeriodTime(new TimeOnly(14, 20, 0), new TimeOnly(15, 50, 0))}, + {5, new ScheduleSettings.PairPeriodTime(new TimeOnly(16, 20, 0), new TimeOnly(17, 50, 0))}, + {6, new ScheduleSettings.PairPeriodTime(new TimeOnly(18, 0, 0), new TimeOnly(19, 30, 0))}, + {7, new ScheduleSettings.PairPeriodTime(new TimeOnly(19, 40, 0), new TimeOnly(21, 10, 0))}, + } }; if (!CronExpression.TryParse(general.ScheduleSettings.CronUpdateSchedule, CronFormat.Standard, out _))