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)