k
This commit is contained in:
parent
17f644cf7b
commit
ea30177fe1
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ShoeStore.Repositories;
|
namespace ShoeStore.Repositories;
|
||||||
|
|
||||||
internal interface IConnectionString
|
public interface IConnectionString
|
||||||
{
|
{
|
||||||
string ConnectionString { get; }
|
public string ConnectionString { get; }
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ namespace ShoeStore.Repositories.Implementations;
|
|||||||
|
|
||||||
internal class ConnectionString : IConnectionString
|
internal class ConnectionString : IConnectionString
|
||||||
{
|
{
|
||||||
string IConnectionString.ConnectionString => "";
|
string IConnectionString.ConnectionString => "Server=localhost;Port=5432;Database=BDOTP;User Id=postgres;Password=postgres;";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
using ShoeStore.Entities;
|
using ShoeStore.Entities;
|
||||||
using ShoeStore.Entities.Enums;
|
using ShoeStore.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
@ -32,7 +33,7 @@ internal class FactoryRepository : IFactoryRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Factorys (FactoryName, Manufacturer)
|
INSERT INTO Factorys (FactoryName, Manufacturer)
|
||||||
VALUES (@FactoryName, @Manufacturer)";
|
VALUES (@FactoryName, @Manufacturer)";
|
||||||
@ -52,7 +53,7 @@ VALUES (@FactoryName, @Manufacturer)";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"
|
var queryUpdate = @"
|
||||||
UPDATE Factorys
|
UPDATE Factorys
|
||||||
SET
|
SET
|
||||||
@ -75,7 +76,7 @@ WHERE [Id]=@Id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM Factorys
|
DELETE FROM Factorys
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
@ -95,7 +96,7 @@ WHERE Id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT * FROM Factorys
|
SELECT * FROM Factorys
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
using ShoeStore.Entities;
|
using ShoeStore.Entities;
|
||||||
using ShoeStore.Entities.Enums;
|
using ShoeStore.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
@ -30,7 +31,7 @@ internal class ShoesReplenishmentRepository : IShoesReplenishmentRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
@ -66,7 +67,7 @@ VALUES (@ShoesReplenishmentId,@ShoesId, @Count)";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM ShoesReplenishments
|
DELETE FROM ShoesReplenishments
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
@ -86,7 +87,7 @@ WHERE Id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM ShoesReplenishments";
|
var querySelect = @"SELECT * FROM ShoesReplenishments";
|
||||||
var shoesReplenishments =
|
var shoesReplenishments =
|
||||||
connection.Query<ShoesReplenishment>(querySelect);
|
connection.Query<ShoesReplenishment>(querySelect);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualBasic.FileIO;
|
using Microsoft.VisualBasic.FileIO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
using ShoeStore.Entities;
|
using ShoeStore.Entities;
|
||||||
using ShoeStore.Entities.Enums;
|
using ShoeStore.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
@ -31,7 +32,7 @@ internal class ShoesRepository : IShoesRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Shoess (ShoesType, Name, Description)
|
INSERT INTO Shoess (ShoesType, Name, Description)
|
||||||
VALUES (@ShoesType, @Name, @Description)";
|
VALUES (@ShoesType, @Name, @Description)";
|
||||||
@ -51,7 +52,7 @@ VALUES (@ShoesType, @Name, @Description)";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"
|
var queryUpdate = @"
|
||||||
UPDATE Shoess
|
UPDATE Shoess
|
||||||
SET
|
SET
|
||||||
@ -74,7 +75,7 @@ WHERE Id=@Id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM Shoess
|
DELETE FROM Shoess
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
@ -93,7 +94,7 @@ WHERE Id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT * FROM Shoess
|
SELECT * FROM Shoess
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
@ -117,7 +118,7 @@ WHERE Id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Shoess";
|
var querySelect = "SELECT * FROM Shoess";
|
||||||
var shoess = connection.Query<Shoes>(querySelect);
|
var shoess = connection.Query<Shoes>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
using ShoeStore.Entities;
|
using ShoeStore.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -29,7 +30,7 @@ internal class ShoesSaleRepository : IShoesSaleRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO ShoesSales (ShoesId, FactoryId, StoreId, SaleDate, Specificity)
|
INSERT INTO ShoesSales (ShoesId, FactoryId, StoreId, SaleDate, Specificity)
|
||||||
VALUES (@ShoesId, @FactoryId, @StoreId, @SaleDate, @Specificity)";
|
VALUES (@ShoesId, @FactoryId, @StoreId, @SaleDate, @Specificity)";
|
||||||
@ -49,7 +50,7 @@ VALUES (@ShoesId, @FactoryId, @StoreId, @SaleDate, @Specificity)";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM ShoesSales";
|
var querySelect = "SELECT * FROM ShoesSales";
|
||||||
var shoesSales =
|
var shoesSales =
|
||||||
connection.Query<ShoesSale>(querySelect);
|
connection.Query<ShoesSale>(querySelect);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
using ShoeStore.Entities;
|
using ShoeStore.Entities;
|
||||||
using ShoeStore.Entities.Enums;
|
using ShoeStore.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
@ -30,7 +31,7 @@ internal class StoreRepository : IStoreRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Stores (StoreType, StoreName, Employees, Visitors)
|
INSERT INTO Stores (StoreType, StoreName, Employees, Visitors)
|
||||||
VALUES (@StoreType, @StoreName, @Employees, @Visitors)";
|
VALUES (@StoreType, @StoreName, @Employees, @Visitors)";
|
||||||
@ -49,7 +50,7 @@ VALUES (@StoreType, @StoreName, @Employees, @Visitors)";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"
|
var queryUpdate = @"
|
||||||
UPDATE Store
|
UPDATE Store
|
||||||
SET
|
SET
|
||||||
@ -74,7 +75,7 @@ WHERE Id=@Id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM Store
|
DELETE FROM Store
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
@ -94,7 +95,7 @@ WHERE Id=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT * FROM Store
|
SELECT * FROM Store
|
||||||
WHERE [Id]=@id";
|
WHERE [Id]=@id";
|
||||||
@ -118,7 +119,7 @@ WHERE [Id]=@id";
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
SqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Stores";
|
var querySelect = "SELECT * FROM Stores";
|
||||||
var stores = connection.Query<Store>(querySelect);
|
var stores = connection.Query<Store>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(stores));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(stores));
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Npgsql" Version="9.0.2" />
|
||||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||||
|
Loading…
Reference in New Issue
Block a user