легкие правочки
This commit is contained in:
parent
6a4c42fe23
commit
d7c7379b5f
@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user