PI2024-23 #2

Merged
s464958 merged 21 commits from PI2024-23 into master 2024-06-14 14:47:25 +02:00
2 changed files with 22 additions and 6 deletions
Showing only changes of commit 43c4e20908 - Show all commits

View File

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

View File

@ -9,6 +9,7 @@ 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; }
} }
} }