From b005975c8128ff530aab27bfc6de021767d3b639 Mon Sep 17 00:00:00 2001
From: LD-Reborn
Date: Sun, 30 Nov 2025 10:28:50 +0100
Subject: [PATCH] Fixed localization issues, fixed text-warning not accessible,
---
Controllers/OrderController.cs | 27 ++++++++++++++++++++++++---
Program.cs | 10 +++++++++-
Resources/SharedResources.de.resx | 14 +++++++++++++-
Resources/SharedResources.en.resx | 14 +++++++++++++-
Services/LocalizationService.cs | 1 +
Views/Home/Dashboard.cshtml | 8 +++-----
Views/Order/Create.cshtml | 6 +++---
Views/Order/Details.cshtml | 12 ++++++++----
Views/Order/Join.cshtml | 2 +-
Views/Shared/_Layout.cshtml | 2 +-
10 files changed, 76 insertions(+), 20 deletions(-)
diff --git a/Controllers/OrderController.cs b/Controllers/OrderController.cs
index 34b6a9c..a98f514 100644
--- a/Controllers/OrderController.cs
+++ b/Controllers/OrderController.cs
@@ -24,7 +24,7 @@ public class OrderController : Controller
// POST: Order/Create
[HttpPost]
- public async Task Create(Order order, string[] itemNames, decimal[] itemPrices)
+ public async Task 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 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();
diff --git a/Program.cs b/Program.cs
index c939daa..c5f88cc 100644
--- a/Program.cs
+++ b/Program.cs
@@ -80,7 +80,15 @@ if (!app.Environment.IsDevelopment())
}
app.UseHttpsRedirection();
-app.UseRequestLocalization();
+
+// Add localization
+var supportedCultures = new[] { "de", "de-DE", "en-US" };
+var localizationOptions = new RequestLocalizationOptions()
+ .SetDefaultCulture("de")
+ .AddSupportedCultures(supportedCultures)
+ .AddSupportedUICultures(supportedCultures);
+
+app.UseRequestLocalization(localizationOptions);
app.UseRouting();
app.UseAuthentication();
diff --git a/Resources/SharedResources.de.resx b/Resources/SharedResources.de.resx
index c1d8b27..6fef943 100644
--- a/Resources/SharedResources.de.resx
+++ b/Resources/SharedResources.de.resx
@@ -100,7 +100,7 @@
Gesamt
- Ich schulde
+ Offener Betrag
Mehr hinzufügen
@@ -267,4 +267,16 @@
Registrierung erfolgreich! Leitung zum Login...
+
+ Erstellt
+
+
+ Meine Artikel
+
+
+ €
+
+
+ {0} €
+
\ No newline at end of file
diff --git a/Resources/SharedResources.en.resx b/Resources/SharedResources.en.resx
index 3d739bf..45c2430 100644
--- a/Resources/SharedResources.en.resx
+++ b/Resources/SharedResources.en.resx
@@ -100,7 +100,7 @@
Total
- I owe
+ Outstanding amount
Add More
@@ -267,4 +267,16 @@
Registration successful! Redirecting to login...
+
+ Created
+
+
+ My Items
+
+
+ $
+
+
+ ${0}
+
\ No newline at end of file
diff --git a/Services/LocalizationService.cs b/Services/LocalizationService.cs
index c47286c..a8da1dc 100644
--- a/Services/LocalizationService.cs
+++ b/Services/LocalizationService.cs
@@ -14,4 +14,5 @@ public class LocalizationService
public string Get(string key) => _localizer[key];
public string this[string key] => _localizer[key];
+ public string this[string key, params object[] args] => _localizer[key, args];
}
\ No newline at end of file
diff --git a/Views/Home/Dashboard.cshtml b/Views/Home/Dashboard.cshtml
index ec4fd82..5eecaba 100644
--- a/Views/Home/Dashboard.cshtml
+++ b/Views/Home/Dashboard.cshtml
@@ -11,8 +11,6 @@
@@ -63,7 +61,7 @@
@Localizer.Get("Created"): @order.CreatedAt.ToString("MMM dd, yyyy HH:mm")
@Localizer.Get("Items"): @order.MenuItems.Count | @Localizer.Get("Orders"): @order.OrderItems.Count
- @Localizer.Get("Total"): $@order.OrderItems.Sum(oi => oi.MenuItem.Price * oi.Quantity).ToString("F2")
+ @Localizer.Get("Total"): @Localizer["Currency", order.OrderItems.Sum(oi => oi.MenuItem.Price * oi.Quantity).ToString("F2")]
@Localizer.Get("View")
@if (!order.IsClosed)
@@ -72,7 +70,7 @@
}
else
{
-
@Localizer.Get("Closed")
+
@Localizer.Get("Closed")
}
@@ -109,7 +107,7 @@
@Localizer.Get("CreatedBy"): @order.CreatorName
@Localizer.Get("MyItems"): @myItems.Count
- @Localizer.Get("IOwe"): $@myItems.Sum(oi => oi.MenuItem.Price * oi.Quantity).ToString("F2")
+ @Localizer.Get("IOwe"): @Localizer["Currency", myItems.Sum(oi => (oi.MenuItem?.Price ?? 0) * oi.Quantity).ToString("F2")]
@Localizer.Get("View")
@if (!order.IsClosed)
diff --git a/Views/Order/Create.cshtml b/Views/Order/Create.cshtml
index 4710207..35748b5 100644
--- a/Views/Order/Create.cshtml
+++ b/Views/Order/Create.cshtml
@@ -15,7 +15,7 @@
@@ -67,7 +67,7 @@ document.getElementById('addItemBtn').addEventListener('click', function() {
- $
+ @Localizer["CurrencySymbol"]
diff --git a/Views/Order/Details.cshtml b/Views/Order/Details.cshtml
index fbac13e..81760bf 100644
--- a/Views/Order/Details.cshtml
+++ b/Views/Order/Details.cshtml
@@ -38,7 +38,7 @@
{
| @item.Name |
- $@item.Price.ToString("F2") |
+ @Localizer["Currency", item.Price.ToString("F2")] |
}
@@ -74,7 +74,7 @@
@orderItem.ParticipantName |
@orderItem.MenuItem?.Name |
@orderItem.Quantity |
-
$@(orderItem.MenuItem?.Price * orderItem.Quantity ?? 0).ToString("F2") |
+
@Localizer["Currency", (orderItem.MenuItem?.Price * orderItem.Quantity ?? 0).ToString("F2")] |
}
@@ -105,13 +105,17 @@
@Localizer.Get("QuickStats")
@Localizer.Get("TotalItems"): @Model.MenuItems.Count
@Localizer.Get("TotalOrders"): @Model.OrderItems.Count
-
@Localizer.Get("TotalRevenue"): $@Model.OrderItems.Sum(oi => oi.MenuItem.Price * oi.Quantity).ToString("F2")
+
@Localizer.Get("TotalRevenue"): @Localizer["Currency", Model.OrderItems.Sum(oi => oi.MenuItem.Price * oi.Quantity).ToString("F2")]
@if (!Model.IsClosed)
{
- @Localizer.Get("CloseOrder")
+ @Localizer.Get("CloseOrder")
+ }
+ else
+ {
+ @Localizer.Get("Closed")
}
diff --git a/Views/Order/Join.cshtml b/Views/Order/Join.cshtml
index 2afa164..2457d75 100644
--- a/Views/Order/Join.cshtml
+++ b/Views/Order/Join.cshtml
@@ -12,7 +12,7 @@
-
@Model.CreatorName
+
@Model.Name
@Localizer["Code"]: @Model.OrderCode
@Localizer["CreatedBy"]: @Model.CreatorName
diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml
index 0215a2a..1cef614 100644
--- a/Views/Shared/_Layout.cshtml
+++ b/Views/Shared/_Layout.cshtml
@@ -44,7 +44,7 @@