PI2024-23 #2
@ -55,9 +55,16 @@ namespace FirmTracker_Server.Controllers
|
|||||||
|
|
||||||
foreach (var product in transaction.TransactionProducts)
|
foreach (var product in transaction.TransactionProducts)
|
||||||
{
|
{
|
||||||
|
var productByName = _productCRUD.GetProductByName(product.ProductName);
|
||||||
|
if (productByName == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Product with name {product.ProductName} does not exist.");
|
||||||
|
}
|
||||||
|
product.ProductID = productByName.Id;
|
||||||
product.TransactionId = transaction.Id;
|
product.TransactionId = transaction.Id;
|
||||||
decimal price = _productCRUD.GetProductPrice(product.ProductID);
|
|
||||||
int type = _productCRUD.GetProductType(product.ProductID);
|
decimal price = productByName.Price;// _productCRUD.GetProductPrice(product.ProductID);
|
||||||
|
int type = productByName.Type;//_productCRUD.GetProductType(product.ProductID);
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
{
|
{
|
||||||
var prod = _productCRUD.GetProduct(product.ProductID);
|
var prod = _productCRUD.GetProduct(product.ProductID);
|
||||||
@ -120,8 +127,16 @@ namespace FirmTracker_Server.Controllers
|
|||||||
{
|
{
|
||||||
foreach (var product in transaction.TransactionProducts)
|
foreach (var product in transaction.TransactionProducts)
|
||||||
{
|
{
|
||||||
|
var productByName = _productCRUD.GetProductByName(product.ProductName);
|
||||||
|
if (productByName == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Product with name {product.ProductName} does not exist.");
|
||||||
|
}
|
||||||
|
product.ProductID = productByName.Id;
|
||||||
product.TransactionId = transaction.Id;
|
product.TransactionId = transaction.Id;
|
||||||
decimal price = _productCRUD.GetProductPrice(product.ProductID);
|
|
||||||
|
decimal price = productByName.Price;// _productCRUD.GetProductPrice(product.ProductID);
|
||||||
|
int type = productByName.Type;//_productCRUD.GetProductType(product.ProductID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
{
|
{
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
public virtual int TransactionId { get; set; }
|
public virtual int TransactionId { get; set; }
|
||||||
public virtual int ProductID { get; set; }
|
public virtual int ProductID { get; set; }
|
||||||
|
public virtual string ProductName { get; set; }
|
||||||
public virtual int Quantity { get; set; }
|
public virtual int Quantity { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user