From 7b779463bbd2711c82f374f5b90e14e1ea077d39 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Tue, 28 May 2024 06:59:28 +0300 Subject: [PATCH] feat: add converter from Dto.PairPeriodTime toEnpoint.PairPeriodTime and vice versa --- Endpoint/Common/Services/PairPeriodTimeConverter.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Endpoint/Common/Services/PairPeriodTimeConverter.cs diff --git a/Endpoint/Common/Services/PairPeriodTimeConverter.cs b/Endpoint/Common/Services/PairPeriodTimeConverter.cs new file mode 100644 index 0000000..ad46295 --- /dev/null +++ b/Endpoint/Common/Services/PairPeriodTimeConverter.cs @@ -0,0 +1,13 @@ +using Mirea.Api.Endpoint.Configuration.General.Settings; +using System.Collections.Generic; +using System.Linq; + +namespace Mirea.Api.Endpoint.Common.Services; + +public static class PairPeriodTimeConverter +{ + public static Dictionary ConvertToDto(this IDictionary pairPeriod) => + pairPeriod.ToDictionary(kvp => kvp.Key, kvp => new Dto.Common.PairPeriodTime { Start = kvp.Value.Start, End = kvp.Value.End }); + + public static Dictionary ConvertFromDto(this IDictionary pairPeriod) => pairPeriod.ToDictionary(kvp => kvp.Key, kvp => new ScheduleSettings.PairPeriodTime(kvp.Value.Start, kvp.Value.End)); +}