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 28 additions and 5 deletions
Showing only changes of commit 06f22951c9 - Show all commits

View File

@ -134,7 +134,7 @@ namespace FirmTracker_Server.Controllers
{
product.TransactionId = transaction.Id;
decimal price = _productCRUD.GetProductPrice(product.ProductID);
transaction.TotalPrice += ((product.Quantity * price) * ((1 - (transaction.Discount / 100))));
//transaction.TotalPrice += ((product.Quantity * price) * ((1 - (transaction.Discount / 100))));
}
transaction.TotalPrice = Math.Round(transaction.TotalPrice, 2, MidpointRounding.AwayFromZero);

View File

@ -86,9 +86,30 @@ namespace FirmTracker_Server.nHibernate.Transactions
{
try
{
var oldTransaction = session.Load<Transaction>(transaction.Id);
foreach (var tp in oldTransaction.TransactionProducts)
{
var product = session.Get<Product>(tp.ProductID);
Console.WriteLine($"Product {product.Name} before quantity: {tp.Quantity}");
if (product.Type != 0)
{
product.Availability += tp.Quantity;
transaction.TotalPrice -= ((tp.Quantity * product.Price) * ((1 - (transaction.Discount / 100))));
}
else
{
transaction.TotalPrice -= (product.Price) * ((1 - (transaction.Discount / 100)));
}
session.Update(product);
}
session.Flush();
session.Clear();
foreach (var transactionProduct in transaction.TransactionProducts)
{
/*var product = session.Get<Product>(transactionProduct.ProductID);
var product = session.Get<Product>(transactionProduct.ProductID);
if (product.Type != 0)
{
transaction.TotalPrice += ((transactionProduct.Quantity * product.Price) * ((1 - (transaction.Discount / 100))));
@ -96,10 +117,13 @@ namespace FirmTracker_Server.nHibernate.Transactions
else
{
transaction.TotalPrice += (product.Price) * ((1 - (transaction.Discount / 100)));
}*/
}
//var product = session.Load<Product>(transactionProduct.ProductID);
Console.WriteLine($"Product {product.Name} after quantity: {transactionProduct.Quantity}");
transactionProduct.TransactionId = transaction.Id;
session.Update(transactionProduct);
session.SaveOrUpdate(transactionProduct);
}
session.Update(transaction);
@ -114,7 +138,6 @@ namespace FirmTracker_Server.nHibernate.Transactions
session.Update(product);
}
}
sessionTransaction.Commit();
}
catch