PI2024-23 #2

Merged
s464958 merged 21 commits from PI2024-23 into master 2024-06-14 14:47:25 +02:00
4 changed files with 13 additions and 17 deletions
Showing only changes of commit 321ce311de - Show all commits

View File

@ -41,11 +41,11 @@ namespace FirmTracker_Server.Controllers
{
if (product.Type != 0 && product.Type != 1)
{
return BadRequest("Product type must be set to 0 or 1");
return BadRequest("Kategoria produktu musi być ustawiona na 0 lub 1.");
}
if (product.Type == 0 && product.Availability != 0)
{
return BadRequest("Services availability must be set to 0");
return BadRequest("Dostępność usługi musi być ustawiona na 0.");
}
try
{
@ -88,14 +88,14 @@ namespace FirmTracker_Server.Controllers
public IActionResult UpdateProduct(int id, [FromBody] Product product)
{
if (id != product.Id)
return BadRequest("Product ID mismatch");
return BadRequest("ID produktu nie zgadza się.");
if (product.Type != 0 && product.Type != 1)
{
return BadRequest("Product type must be set to 0 or 1");
return BadRequest("Kategoria produktu musi być ustawiona na 0 lub 1.");
}
if (product.Type == 0 && product.Availability != 0)
{
return BadRequest("Services availability must be set to 0");
return BadRequest("Dostępność usługi musi być ustawiona na 0.");
}
try
@ -149,7 +149,7 @@ namespace FirmTracker_Server.Controllers
var product = _productCrud.GetProduct(order.ProductId);
if (product == null)
{
return BadRequest($"Product with ID {order.ProductId} not found.");
return BadRequest($"Nie znaleziono produktu o ID {order.ProductId}.");
}
totalPrice += product.Price * order.Quantity;
}

View File

@ -51,7 +51,7 @@ namespace FirmTracker_Server.Controllers
var toDate = dateRange.ToDate;
if (fromDate >= toDate)
{
return BadRequest();
return BadRequest("Nieprawidłowy zakres dat.");
}
using (var session = SessionFactory.OpenSession())
{
@ -191,7 +191,7 @@ namespace FirmTracker_Server.Controllers
var toDate = dateRange.ToDate;
if (fromDate >= toDate)
{
return BadRequest();
return BadRequest("Nieprawidłowy zakres dat.");
}
var transactions = session.Query<nHibernate.Transactions.Transaction>()
.Where(t => t.Date >= fromDate && t.Date <= toDate)

View File

@ -58,7 +58,7 @@ namespace FirmTracker_Server.Controllers
var productByName = _productCRUD.GetProductByName(product.ProductName);
if (productByName == null)
{
throw new InvalidOperationException($"Product with name {product.ProductName} does not exist.");
throw new InvalidOperationException($"Produkt o nazwie {product.ProductName} nie istnieje.");
}
product.ProductID = productByName.Id;
product.TransactionId = transaction.Id;
@ -71,7 +71,7 @@ namespace FirmTracker_Server.Controllers
if (product.Quantity > prod.Availability)
{
throw new InvalidOperationException($"Can't add product {prod.Name} to transaction. Available: {prod.Availability}, Desired: {product.Quantity}");
throw new InvalidOperationException($"Nie można dodać {prod.Name} do transakcji. Dostępność: {prod.Availability}, Zażądano: {product.Quantity}");
//return BadRequest($"Can't add product {product.ProductID} to transaction. Available: {availability}, Desired: {product.Quantity}");
}
}
@ -121,7 +121,7 @@ namespace FirmTracker_Server.Controllers
public IActionResult UpdateTransaction(int id, [FromBody] nHibernate.Transactions.Transaction transaction)
{
if (id != transaction.Id)
return BadRequest("Transaction ID mismatch");
return BadRequest("ID transakcji nie zgadza się.");
try
{
@ -130,7 +130,7 @@ namespace FirmTracker_Server.Controllers
var productByName = _productCRUD.GetProductByName(product.ProductName);
if (productByName == null)
{
throw new InvalidOperationException($"Product with name {product.ProductName} does not exist.");
throw new InvalidOperationException($"Produkt o nazwie {product.ProductName} nie istnieje.");
}
product.ProductID = productByName.Id;
product.TransactionId = transaction.Id;

View File

@ -91,7 +91,6 @@ namespace FirmTracker_Server.nHibernate.Transactions
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)
{
@ -116,9 +115,6 @@ namespace FirmTracker_Server.nHibernate.Transactions
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.SaveOrUpdate(transactionProduct);
}
@ -134,7 +130,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
{
if (transactionProduct.Quantity > product.Availability)
{
throw new InvalidOperationException($"Can't add product {product.Name} to transaction. Available: {product.Availability}, Desired: {transactionProduct.Quantity}");
throw new InvalidOperationException($"Nie można dodać {product.Name} do transakcji. Dostępność: {product.Availability}, Zażądano: {transactionProduct.Quantity}");
}
else
{