From 2cde8b4735e566f4361fbf0e8d1cb32a094e3330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=A8=D0=B8=D0=BF?= =?UTF-8?q?=D0=B8=D0=BB=D0=BE=D0=B2?= <116575516+LAYT73@users.noreply.github.com> Date: Sun, 8 Dec 2024 21:00:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/IShiftRepository.cs | 2 +- .../Implementations/ShiftRepository.cs | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/ProjectGasStation/ProjectGasStation/Repositories/IShiftRepository.cs b/ProjectGasStation/ProjectGasStation/Repositories/IShiftRepository.cs index 63ca941..73c4ece 100644 --- a/ProjectGasStation/ProjectGasStation/Repositories/IShiftRepository.cs +++ b/ProjectGasStation/ProjectGasStation/Repositories/IShiftRepository.cs @@ -4,7 +4,7 @@ namespace ProjectGasStation.Repositories; public interface IShiftRepository { - IEnumerable ReadShifts(DateTime? dateFrom = null, DateTime? dateTo = null); + IEnumerable ReadShifts(); Shift ReadShiftById(int id); void CreateShift(Shift shift); void UpdateShift(Shift shift); diff --git a/ProjectGasStation/ProjectGasStation/Repositories/Implementations/ShiftRepository.cs b/ProjectGasStation/ProjectGasStation/Repositories/Implementations/ShiftRepository.cs index c0d898e..5832d12 100644 --- a/ProjectGasStation/ProjectGasStation/Repositories/Implementations/ShiftRepository.cs +++ b/ProjectGasStation/ProjectGasStation/Repositories/Implementations/ShiftRepository.cs @@ -78,23 +78,14 @@ public class ShiftRepository : IShiftRepository } } - public IEnumerable ReadShifts(DateTime? dateFrom = null, DateTime? dateTo = null) + public IEnumerable ReadShifts() { _logger.LogInformation("Получение всех объектов"); try { - var builder = new QueryBuilder(); - if (dateFrom.HasValue) - { - builder.AddCondition("Date >= @dateFrom"); - } - if (dateTo.HasValue) - { - builder.AddCondition("Date <= @dateTo"); - } using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = $"SELECT * FROM Shift {builder.Build()}"; - var shifts = connection.Query(querySelect, new { dateFrom, dateTo }); + var querySelect = "SELECT * FROM Shift"; + var shifts = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(shifts)); return shifts;