Лабораторная работа №2
This commit is contained in:
parent
46658bd340
commit
7a0c58ab6c
@ -19,7 +19,7 @@ public class Invoice
|
|||||||
|
|
||||||
public int SellingPrice { get; set; }
|
public int SellingPrice { get; set; }
|
||||||
|
|
||||||
DateTime Data { get; set; }
|
DateTime DateInvoice { get; set; }
|
||||||
|
|
||||||
public IEnumerable<InvoiceProduct> Products
|
public IEnumerable<InvoiceProduct> Products
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ public class Invoice
|
|||||||
AvailabilityOfPromotionalCode = availabilityOfPromotionalCode,
|
AvailabilityOfPromotionalCode = availabilityOfPromotionalCode,
|
||||||
DiscountPercentage = discountPercentage,
|
DiscountPercentage = discountPercentage,
|
||||||
SellingPrice = sellingPrice,
|
SellingPrice = sellingPrice,
|
||||||
Data = DateTime.Now,
|
DateInvoice = DateTime.Now,
|
||||||
Products = products
|
Products = products
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@ public class InvoiceProduct
|
|||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public int SellingPrice { get; private set; }
|
|
||||||
|
|
||||||
public static InvoiceProduct CreateElement(int invoiceId, int productID, int count)
|
public static InvoiceProduct CreateElement(int invoiceId, int productID, int count)
|
||||||
{
|
{
|
||||||
return new InvoiceProduct
|
return new InvoiceProduct
|
||||||
|
@ -55,9 +55,7 @@ namespace ProjectCompanyFurniture.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxName.Text)
|
if (string.IsNullOrWhiteSpace(textBoxName.Text) || comboBoxClientType.SelectedIndex < 1)
|
||||||
|| checkBoxOptYes.Checked == false
|
|
||||||
|| comboBoxClientType.SelectedIndex < 1)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
// numericUpDownDiscPercentage
|
// numericUpDownDiscPercentage
|
||||||
//
|
//
|
||||||
numericUpDownDiscPercentage.Location = new Point(213, 141);
|
numericUpDownDiscPercentage.Location = new Point(213, 141);
|
||||||
|
numericUpDownDiscPercentage.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
|
||||||
numericUpDownDiscPercentage.Name = "numericUpDownDiscPercentage";
|
numericUpDownDiscPercentage.Name = "numericUpDownDiscPercentage";
|
||||||
numericUpDownDiscPercentage.Size = new Size(150, 27);
|
numericUpDownDiscPercentage.Size = new Size(150, 27);
|
||||||
numericUpDownDiscPercentage.TabIndex = 20;
|
numericUpDownDiscPercentage.TabIndex = 20;
|
||||||
@ -154,6 +155,7 @@
|
|||||||
// numericUpDownSellingPrice
|
// numericUpDownSellingPrice
|
||||||
//
|
//
|
||||||
numericUpDownSellingPrice.Location = new Point(212, 194);
|
numericUpDownSellingPrice.Location = new Point(212, 194);
|
||||||
|
numericUpDownSellingPrice.Maximum = new decimal(new int[] { 10000000, 0, 0, 0 });
|
||||||
numericUpDownSellingPrice.Name = "numericUpDownSellingPrice";
|
numericUpDownSellingPrice.Name = "numericUpDownSellingPrice";
|
||||||
numericUpDownSellingPrice.Size = new Size(151, 27);
|
numericUpDownSellingPrice.Size = new Size(151, 27);
|
||||||
numericUpDownSellingPrice.TabIndex = 23;
|
numericUpDownSellingPrice.TabIndex = 23;
|
||||||
|
@ -24,7 +24,7 @@ namespace ProjectCompanyFurniture.Forms
|
|||||||
throw new ArgumentNullException(nameof(invoiceRepository));
|
throw new ArgumentNullException(nameof(invoiceRepository));
|
||||||
|
|
||||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||||
comboBoxClient.DisplayMember = "FirstName";
|
comboBoxClient.DisplayMember = "Name";
|
||||||
comboBoxClient.ValueMember = "ID";
|
comboBoxClient.ValueMember = "ID";
|
||||||
|
|
||||||
ColumnProduct.DataSource = productRepository.ReadProducts();
|
ColumnProduct.DataSource = productRepository.ReadProducts();
|
||||||
@ -36,7 +36,7 @@ namespace ProjectCompanyFurniture.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0 || checkBoxPromYes.Checked == false)
|
if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
// numericUpDownStartPrice
|
// numericUpDownStartPrice
|
||||||
//
|
//
|
||||||
numericUpDownStartPrice.Location = new Point(211, 220);
|
numericUpDownStartPrice.Location = new Point(211, 220);
|
||||||
|
numericUpDownStartPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
|
||||||
numericUpDownStartPrice.Name = "numericUpDownStartPrice";
|
numericUpDownStartPrice.Name = "numericUpDownStartPrice";
|
||||||
numericUpDownStartPrice.Size = new Size(125, 27);
|
numericUpDownStartPrice.Size = new Size(125, 27);
|
||||||
numericUpDownStartPrice.TabIndex = 5;
|
numericUpDownStartPrice.TabIndex = 5;
|
||||||
|
@ -42,7 +42,7 @@ namespace ProjectCompanyFurniture.Forms
|
|||||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||||
|
|
||||||
comboBoxManufacturer.DataSource = manufacturerRepository.ReadManufacturers();
|
comboBoxManufacturer.DataSource = manufacturerRepository.ReadManufacturers();
|
||||||
comboBoxManufacturer.DisplayMember = "FirstName";
|
comboBoxManufacturer.DisplayMember = "Name";
|
||||||
comboBoxManufacturer.ValueMember = "Id";
|
comboBoxManufacturer.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ namespace ProjectCompanyFurniture.Forms
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var form = _container.Resolve<FormClient>();
|
var form = _container.Resolve<FormProduct>();
|
||||||
form.Id = findId;
|
form.Id = findId;
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadList();
|
LoadList();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<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" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Sstv.Outbox.Npgsql" Version="2.0.0" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
||||||
<PackageReference Include="Unity" Version="5.11.10" />
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
<PackageReference Include="Unity.Container" Version="5.11.11" />
|
<PackageReference Include="Unity.Container" Version="5.11.11" />
|
||||||
|
@ -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 ProjectCompanyFurniture.Entities;
|
using ProjectCompanyFurniture.Entities;
|
||||||
using ProjectCompanyFurniture.Entities.Enums;
|
using ProjectCompanyFurniture.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
@ -29,7 +30,7 @@ public class ClientRepository : IClientRepository
|
|||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"INSERT INTO Clients (Name, ClientType, Optovik)
|
var queryInsert = @"INSERT INTO Clients (Name, ClientType, Optovik)
|
||||||
VALUES (@Name, @ClientType, @Optovik)";
|
VALUES (@Name, @ClientType, @Optovik)";
|
||||||
connection.Execute(queryInsert, client);
|
connection.Execute(queryInsert, client);
|
||||||
@ -48,7 +49,7 @@ public class ClientRepository : IClientRepository
|
|||||||
JsonConvert.SerializeObject(client));
|
JsonConvert.SerializeObject(client));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"UPDATE Clients SET
|
var queryUpdate = @"UPDATE Clients SET
|
||||||
Name=@Name,
|
Name=@Name,
|
||||||
ClientType=@ClientType,
|
ClientType=@ClientType,
|
||||||
@ -69,7 +70,7 @@ public class ClientRepository : IClientRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"DELETE FROM Clients WHERE ID=@id";
|
var queryDelete = @"DELETE FROM Clients WHERE ID=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ public class ClientRepository : IClientRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM Clients WHERE [ID]=@id";
|
var querySelect = @"SELECT * FROM Clients WHERE [ID]=@id";
|
||||||
var client = connection.QueryFirst<Client>(querySelect, new
|
var client = connection.QueryFirst<Client>(querySelect, new
|
||||||
{
|
{
|
||||||
@ -108,7 +109,7 @@ public class ClientRepository : IClientRepository
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Clients";
|
var querySelect = "SELECT * FROM Clients";
|
||||||
var clients = connection.Query<Client>(querySelect);
|
var clients = connection.Query<Client>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
@ -8,5 +8,8 @@ namespace ProjectCompanyFurniture.Repositories.Implementations;
|
|||||||
|
|
||||||
public class ConnectionString : IConnectionString
|
public class ConnectionString : IConnectionString
|
||||||
{
|
{
|
||||||
string IConnectionString.ConnectionString => "Driver={PostgreSQL};Server=localhost;Port=5432;Database=furnitureotp;Uid=postgres;Pwd=postgres";
|
string IConnectionString.ConnectionString =>
|
||||||
|
"Server=localhost, 5432;Database=furnitureotp;Uid=postgres;Pwd=postgres;"
|
||||||
|
/*"Server=localhost;Port=5432Database=furnitureotp;"*/
|
||||||
|
/* "Host=localhost;Port=5432;Database=furnitureotp;Username=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 ProjectCompanyFurniture.Entities;
|
using ProjectCompanyFurniture.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -28,14 +29,14 @@ public class InvoiceRepository : IInvoiceRepository
|
|||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(invoice));
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(invoice));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"INSERT INTO Invoices (ClientID, AvailabilityOfPromotionalCode,
|
var queryInsert = @"INSERT INTO Invoices (ClientID, AvailabilityOfPromotionalCode,
|
||||||
DiscountPercentage, SellingPrice, Data)
|
DiscountPercentage, SellingPrice, DateInvoice)
|
||||||
VALUES (@ClientID, @AvailabilityOfPromotionalCode,
|
VALUES (@ClientID, @AvailabilityOfPromotionalCode,
|
||||||
@DiscountPercentage, @SellingPrice, @Data);
|
@DiscountPercentage, @SellingPrice, @DateInvoice);
|
||||||
SELECT MAX(Id) FROM FeedReplenishments";
|
SELECT MAX(Id) FROM Invoices";
|
||||||
var invoiceID = connection.QueryFirst<int>(queryInsert, invoice, transaction);
|
var invoiceID = connection.QueryFirst<int>(queryInsert, invoice, transaction);
|
||||||
var querySubInsert = @"INSERT INTO InvoiceProducts (InvoiceId, ProductId, Count, SellingPrice)
|
var querySubInsert = @"INSERT INTO InvoiceProducts (InvoiceId, ProductId, Count, SellingPrice)
|
||||||
VALUES (@InvoiceId, @ProductId, @Count, @SellingPrice)";
|
VALUES (@InvoiceId, @ProductId, @Count, @SellingPrice)";
|
||||||
@ -63,7 +64,7 @@ public class InvoiceRepository : IInvoiceRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"DELETE FROM Invoices
|
var queryDelete = @"DELETE FROM Invoices
|
||||||
WHERE ID=@id";
|
WHERE ID=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
@ -80,7 +81,7 @@ public class InvoiceRepository : IInvoiceRepository
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM Invoices";
|
var querySelect = @"SELECT * FROM Invoices";
|
||||||
var invoices = connection.Query<Invoice>(querySelect);
|
var invoices = connection.Query<Invoice>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(invoices));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(invoices));
|
||||||
|
@ -8,6 +8,7 @@ using System.Data.SqlClient;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Npgsql;
|
||||||
|
|
||||||
namespace ProjectCompanyFurniture.Repositories.Implementations;
|
namespace ProjectCompanyFurniture.Repositories.Implementations;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class ManufacturerRepository : IManufacturerRepository
|
|||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(manufacturer));
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(manufacturer));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"INSERT INTO Manufacturers (Name)
|
var queryInsert = @"INSERT INTO Manufacturers (Name)
|
||||||
VALUES (@Name)";
|
VALUES (@Name)";
|
||||||
connection.Execute(queryInsert, manufacturer);
|
connection.Execute(queryInsert, manufacturer);
|
||||||
@ -47,7 +48,7 @@ public class ManufacturerRepository : IManufacturerRepository
|
|||||||
JsonConvert.SerializeObject(manufacturer));
|
JsonConvert.SerializeObject(manufacturer));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"UPDATE Manufacturers SET
|
var queryUpdate = @"UPDATE Manufacturers SET
|
||||||
Name=@Name
|
Name=@Name
|
||||||
WHERE ID=@id";
|
WHERE ID=@id";
|
||||||
@ -66,7 +67,7 @@ public class ManufacturerRepository : IManufacturerRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"DELETE FROM Manufacturers WHERE ID=@id";
|
var queryDelete = @"DELETE FROM Manufacturers WHERE ID=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
}
|
}
|
||||||
@ -83,7 +84,7 @@ public class ManufacturerRepository : IManufacturerRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM Manufacturers WHERE [ID]=@id";
|
var querySelect = @"SELECT * FROM Manufacturers WHERE [ID]=@id";
|
||||||
var manufacturer = connection.QueryFirst<Manufacturer>(querySelect, new
|
var manufacturer = connection.QueryFirst<Manufacturer>(querySelect, new
|
||||||
{
|
{
|
||||||
@ -105,8 +106,8 @@ public class ManufacturerRepository : IManufacturerRepository
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Manufacturers";
|
var querySelect = "SELECT * FROM MANUFACTURERS";
|
||||||
var manufacturers = connection.Query<Manufacturer>(querySelect);
|
var manufacturers = connection.Query<Manufacturer>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonConvert.SerializeObject(manufacturers));
|
JsonConvert.SerializeObject(manufacturers));
|
||||||
|
@ -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 ProjectCompanyFurniture.Entities;
|
using ProjectCompanyFurniture.Entities;
|
||||||
using ProjectCompanyFurniture.Entities.Enums;
|
using ProjectCompanyFurniture.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
@ -29,7 +30,7 @@ public class ProductMovementRepository : IProductMovementRepository
|
|||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(productMovement));
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(productMovement));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"INSERT INTO ProductMovements (ProductID, MovementType, Date)
|
var queryInsert = @"INSERT INTO ProductMovements (ProductID, MovementType, Date)
|
||||||
VALUES (@ProductID, @MovementType, @Date)";
|
VALUES (@ProductID, @MovementType, @Date)";
|
||||||
connection.Execute(queryInsert, productMovement);
|
connection.Execute(queryInsert, productMovement);
|
||||||
@ -46,7 +47,7 @@ public class ProductMovementRepository : IProductMovementRepository
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM ProductMovements";
|
var querySelect = "SELECT * FROM ProductMovements";
|
||||||
var productMovements = connection.Query<ProductMovement>(querySelect);
|
var productMovements = connection.Query<ProductMovement>(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 ProjectCompanyFurniture.Entities;
|
using ProjectCompanyFurniture.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -28,7 +29,7 @@ public class ProductRepository : IProductRepository
|
|||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"INSERT INTO Products (ManufacturerID, Name, Category, StartingPrice)
|
var queryInsert = @"INSERT INTO Products (ManufacturerID, Name, Category, StartingPrice)
|
||||||
VALUES (@ManufacturerID, @Name, @Category, @StartingPrice)";
|
VALUES (@ManufacturerID, @Name, @Category, @StartingPrice)";
|
||||||
connection.Execute(queryInsert, product);
|
connection.Execute(queryInsert, product);
|
||||||
@ -47,7 +48,7 @@ public class ProductRepository : IProductRepository
|
|||||||
JsonConvert.SerializeObject(product));
|
JsonConvert.SerializeObject(product));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"UPDATE Products SET
|
var queryUpdate = @"UPDATE Products SET
|
||||||
ManufacturerID=@ManufacturerID,
|
ManufacturerID=@ManufacturerID,
|
||||||
Name=@Name,
|
Name=@Name,
|
||||||
@ -69,7 +70,7 @@ public class ProductRepository : IProductRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"DELETE FROM Productss WHERE ID=@id";
|
var queryDelete = @"DELETE FROM Productss WHERE ID=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
}
|
}
|
||||||
@ -86,8 +87,8 @@ public class ProductRepository : IProductRepository
|
|||||||
_logger.LogDebug("Объект: {id}", id);
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM Products WHERE [ID]=@id";
|
var querySelect = @"SELECT * FROM Products WHERE ID=@id";
|
||||||
var product = connection.QueryFirst<Product>(querySelect, new
|
var product = connection.QueryFirst<Product>(querySelect, new
|
||||||
{
|
{
|
||||||
id
|
id
|
||||||
@ -108,7 +109,7 @@ public class ProductRepository : IProductRepository
|
|||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new SqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Products";
|
var querySelect = "SELECT * FROM Products";
|
||||||
var products = connection.Query<Product>(querySelect);
|
var products = connection.Query<Product>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
Loading…
Reference in New Issue
Block a user