По итогам дня, остается сделать - Приявязать БД, Сделать БД, Реализовать TourRepository.

This commit is contained in:
Tonb73 2024-11-14 17:33:41 +04:00
parent 66c30cdb8c
commit 617b14ec3f

View File

@ -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<TourRepository> _logger;
public TourRepository(IConnectionString connectionString, ILogger<TourRepository> 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)