dodawanie produktu do transakcji po nazwie
This commit is contained in:
parent
3b32e30d00
commit
43c4e20908
@ -55,9 +55,16 @@ namespace FirmTracker_Server.Controllers
|
||||
|
||||
foreach (var product in transaction.TransactionProducts)
|
||||
{
|
||||
product.TransactionId = transaction.Id;
|
||||
decimal price = _productCRUD.GetProductPrice(product.ProductID);
|
||||
int type = _productCRUD.GetProductType(product.ProductID);
|
||||
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;
|
||||
|
||||
decimal price = productByName.Price;// _productCRUD.GetProductPrice(product.ProductID);
|
||||
int type = productByName.Type;//_productCRUD.GetProductType(product.ProductID);
|
||||
if (type == 1)
|
||||
{
|
||||
var prod = _productCRUD.GetProduct(product.ProductID);
|
||||
@ -120,8 +127,16 @@ namespace FirmTracker_Server.Controllers
|
||||
{
|
||||
foreach (var product in transaction.TransactionProducts)
|
||||
{
|
||||
product.TransactionId = transaction.Id;
|
||||
decimal price = _productCRUD.GetProductPrice(product.ProductID);
|
||||
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;
|
||||
|
||||
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 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; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user