Fixed localization issues, fixed text-warning not accessible,

This commit is contained in:
2025-11-30 10:28:50 +01:00
parent db8f2fcdf1
commit b005975c81
10 changed files with 76 additions and 20 deletions

View File

@@ -24,7 +24,7 @@ public class OrderController : Controller
// POST: Order/Create
[HttpPost]
public async Task<IActionResult> Create(Order order, string[] itemNames, decimal[] itemPrices)
public async Task<IActionResult> Create(Order order, string[] itemNames, string[] itemPrices)
{
if (!ModelState.IsValid)
return View();
@@ -38,13 +38,14 @@ public class OrderController : Controller
// Add menu items
for (int i = 0; i < itemNames.Length; i++)
{
if (!string.IsNullOrEmpty(itemNames[i]) && itemPrices[i] > 0)
itemPrices[i] = itemPrices[i].Replace(".", ",");
if (!string.IsNullOrEmpty(itemNames[i]) && decimal.TryParse(itemPrices[i], out var price) && price > 0)
{
_context.MenuItems.Add(new MenuItem
{
OrderId = order.Id,
Name = itemNames[i],
Price = itemPrices[i]
Price = price
});
}
}
@@ -111,6 +112,26 @@ public class OrderController : Controller
return View(order);
}
// GET: Order/Close/{code}
public async Task<IActionResult> Close(string code)
{
var order = await _context.Orders.FirstOrDefaultAsync(o => o.OrderCode == code);
if (order == null)
return NotFound("Order not found");
if (order.IsClosed)
return BadRequest("Order is already closed");
order.IsClosed = true;
order.ClosedAt = DateTime.UtcNow;
_context.Orders.Update(order);
await _context.SaveChangesAsync();
return RedirectToAction("Details", new { code = order.OrderCode });
}
private string GenerateOrderCode()
{
return Guid.NewGuid().ToString().Substring(0, 8).ToUpper();