легкие правочки

This commit is contained in:
Олег Кудринский 2024-12-20 12:55:31 +04:00
parent 6a4c42fe23
commit d7c7379b5f
2 changed files with 4 additions and 8 deletions

View File

@ -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
};
}
}

View File

@ -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);
}