From d7c7379b5f52d9c48498332465286f30400a726e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=9A=D1=83=D0=B4=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Fri, 20 Dec 2024 12:55:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=B5=D0=B3=D0=BA=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectWorkshop/ProjectWorkshop/Entities/Product.cs | 6 +----- .../Repositories/Implementations/ProductRepository.cs | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs index 38e90ad..6002222 100644 --- a/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs @@ -10,11 +10,8 @@ public class Product public double Price { get; private set; } - public DateTime AssemblyDate { get; private set; } - public ProductType ProductType { get; private set; } - public static Product CreateEntity(int id, string productName, double price, ProductType productType) { return new Product @@ -22,8 +19,7 @@ public class Product ID = id, ProductName = productName ?? string.Empty, Price = price, - ProductType = productType, - AssemblyDate = DateTime.Now + ProductType = productType }; } } diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs index c8f7af1..40a0942 100644 --- a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs @@ -30,8 +30,8 @@ public class ProductRepository : IProductRepository { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryInsert = @" - INSERT INTO Product (ProductName, Price, AssemblyDate, ProductType) - VALUES (@ProductName, @Price, @AssemblyDate, @ProductType) + INSERT INTO Product (ProductName, Price, ProductType) + VALUES (@ProductName, @Price, @ProductType) RETURNING ID"; connection.Execute(queryInsert, product); } @@ -50,7 +50,7 @@ public class ProductRepository : IProductRepository using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryUpdate = @" UPDATE Product - SET ProductName=@ProductName, Price=@Price, AssemblyDate=@AssemblyDate, ProductType=@ProductType + SET ProductName=@ProductName, Price=@Price, ProductType=@ProductType WHERE ID=@ID"; connection.Execute(queryUpdate, product); }