From 617b14ec3f360231eff975623d3bbfb3840cc9e8 Mon Sep 17 00:00:00 2001 From: Tonb73 Date: Thu, 14 Nov 2024 17:33:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=20=D0=B8=D1=82=D0=BE=D0=B3=D0=B0?= =?UTF-8?q?=D0=BC=20=D0=B4=D0=BD=D1=8F,=20=D0=BE=D1=81=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20-=20=D0=9F=D1=80=D0=B8=D1=8F=D0=B2=D1=8F=D0=B7=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=91=D0=94,=20=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=91=D0=94,=20=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20TourRepository.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implementations/TourRepository.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/project/ProjectTourAgency/Implementations/TourRepository.cs b/project/ProjectTourAgency/Implementations/TourRepository.cs index 0ca7486..75e9f6a 100644 --- a/project/ProjectTourAgency/Implementations/TourRepository.cs +++ b/project/ProjectTourAgency/Implementations/TourRepository.cs @@ -1,7 +1,10 @@ -using ProjectTourAgency.Enities; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using ProjectTourAgency.Enities; using ProjectTourAgency.Repositories; using System; using System.Collections.Generic; +using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,9 +13,31 @@ namespace ProjectTourAgency.Implementations; public class TourRepository : ITourRepository { + private readonly IConnectionString _connectionString; + + private readonly ILogger _logger; + public TourRepository(IConnectionString connectionString, ILogger logger) + { + _connectionString = connectionString; + _logger = logger; + } public void CreateTour(Tour tour) { + _logger.LogInformation("Добавление объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(tour)); + try + { + using var connection = new SqlConnection(_connectionString.ConnectionString); + connection.Open(); + using var transaction = connection.BeginTransaction(); + var queryInsert; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при добавлении объекта"); + throw; + } } public void DeleteTour(int id)