From db8f2fcdf15a7e61c10ca26641840337d3a7dd6a Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sat, 29 Nov 2025 23:20:18 +0100 Subject: [PATCH] Added missing localization, fixed missing order name --- ...ViewController.cs => AccountController.cs} | 6 +- Controllers/HomeController.cs | 2 +- ...251129215458_AddOrderNameField.Designer.cs | 402 ++++++++++++++++++ .../20251129215458_AddOrderNameField.cs | 29 ++ .../ApplicationDbContextModelSnapshot.cs | 4 + Models/Order.cs | 1 + Resources/SharedResources.de.resx | 36 ++ Resources/SharedResources.en.resx | 36 ++ Views/{AuthView => Account}/Login.cshtml | 22 +- Views/{AuthView => Account}/Register.cshtml | 25 +- Views/Home/Dashboard.cshtml | 4 +- Views/Order/Create.cshtml | 4 +- Views/Order/Details.cshtml | 2 +- Views/Shared/_Layout.cshtml | 7 +- 14 files changed, 548 insertions(+), 32 deletions(-) rename Controllers/{AuthViewController.cs => AccountController.cs} (81%) create mode 100644 Migrations/20251129215458_AddOrderNameField.Designer.cs create mode 100644 Migrations/20251129215458_AddOrderNameField.cs rename Views/{AuthView => Account}/Login.cshtml (76%) rename Views/{AuthView => Account}/Register.cshtml (77%) diff --git a/Controllers/AuthViewController.cs b/Controllers/AccountController.cs similarity index 81% rename from Controllers/AuthViewController.cs rename to Controllers/AccountController.cs index 0403a1e..edda49b 100644 --- a/Controllers/AuthViewController.cs +++ b/Controllers/AccountController.cs @@ -5,11 +5,11 @@ using Microsoft.AspNetCore.Mvc; namespace OneForMe.Controllers; [Route("[controller]")] -public class AuthViewController : Controller +public class AccountController : Controller { private readonly SignInManager _signInManager; - public AuthViewController(SignInManager signInManager) + public AccountController(SignInManager signInManager) { _signInManager = signInManager; } @@ -26,7 +26,7 @@ public class AuthViewController : Controller return View(); } - [HttpPost("Logout")] + [HttpGet("Logout")] public async Task Logout() { await _signInManager.SignOutAsync(); diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 9d2c45c..e1eda25 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -23,7 +23,7 @@ public class HomeController : Controller { return RedirectToAction("Dashboard"); } - return RedirectToAction("Login", "AuthViewController"); + return RedirectToAction("Login", "AccountController"); } public async Task Dashboard() diff --git a/Migrations/20251129215458_AddOrderNameField.Designer.cs b/Migrations/20251129215458_AddOrderNameField.Designer.cs new file mode 100644 index 0000000..e7aa429 --- /dev/null +++ b/Migrations/20251129215458_AddOrderNameField.Designer.cs @@ -0,0 +1,402 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using OneForMe.Data; + +#nullable disable + +namespace OneForMe.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251129215458_AddOrderNameField")] + partial class AddOrderNameField + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.0-rc.2.25502.107"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("OneForMe.Models.MenuItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("MenuItems"); + }); + + modelBuilder.Entity("OneForMe.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClosedAt") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CreatorName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IsClosed") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderCode") + .IsUnique(); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("OneForMe.Models.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MenuItemId") + .HasColumnType("INTEGER"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("OrderedAt") + .HasColumnType("TEXT"); + + b.Property("ParticipantEmail") + .HasColumnType("TEXT"); + + b.Property("ParticipantName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("MenuItemId"); + + b.HasIndex("OrderId"); + + b.ToTable("OrderItems"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OneForMe.Models.MenuItem", b => + { + b.HasOne("OneForMe.Models.Order", "Order") + .WithMany("MenuItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("OneForMe.Models.OrderItem", b => + { + b.HasOne("OneForMe.Models.MenuItem", "MenuItem") + .WithMany("OrderItems") + .HasForeignKey("MenuItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OneForMe.Models.Order", "Order") + .WithMany("OrderItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MenuItem"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("OneForMe.Models.MenuItem", b => + { + b.Navigation("OrderItems"); + }); + + modelBuilder.Entity("OneForMe.Models.Order", b => + { + b.Navigation("MenuItems"); + + b.Navigation("OrderItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20251129215458_AddOrderNameField.cs b/Migrations/20251129215458_AddOrderNameField.cs new file mode 100644 index 0000000..cb9965c --- /dev/null +++ b/Migrations/20251129215458_AddOrderNameField.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace OneForMe.Migrations +{ + /// + public partial class AddOrderNameField : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Name", + table: "Orders", + type: "TEXT", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Name", + table: "Orders"); + } + } +} diff --git a/Migrations/ApplicationDbContextModelSnapshot.cs b/Migrations/ApplicationDbContextModelSnapshot.cs index 7f5382a..6a1ff83 100644 --- a/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Migrations/ApplicationDbContextModelSnapshot.cs @@ -251,6 +251,10 @@ namespace OneForMe.Migrations b.Property("IsClosed") .HasColumnType("INTEGER"); + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + b.Property("OrderCode") .IsRequired() .HasColumnType("TEXT"); diff --git a/Models/Order.cs b/Models/Order.cs index eeae8ed..017a415 100644 --- a/Models/Order.cs +++ b/Models/Order.cs @@ -5,6 +5,7 @@ public class Order public int Id { get; set; } public string OrderCode { get; set; } = string.Empty; public string CreatorName { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime? ClosedAt { get; set; } public bool IsClosed { get; set; } = false; diff --git a/Resources/SharedResources.de.resx b/Resources/SharedResources.de.resx index a9fd1d9..c1d8b27 100644 --- a/Resources/SharedResources.de.resx +++ b/Resources/SharedResources.de.resx @@ -231,4 +231,40 @@ Fügen Sie Artikel hinzu, die Menschen bestellen können + + Anmelden + + + E-Mail + + + Passwort + + + Haben Sie kein Konto? + + + Hier registrieren + + + Ein Fehler ist aufgetreten: + + + Registrieren + + + Passwort bestätigen + + + Haben Sie bereits ein Konto? + + + Hier anmelden + + + Passwörter stimmen nicht überein! + + + Registrierung erfolgreich! Leitung zum Login... + \ No newline at end of file diff --git a/Resources/SharedResources.en.resx b/Resources/SharedResources.en.resx index 2a91762..3d739bf 100644 --- a/Resources/SharedResources.en.resx +++ b/Resources/SharedResources.en.resx @@ -231,4 +231,40 @@ Add items that people can order + + Login + + + Email + + + Password + + + Don't have an account? + + + Register here + + + An error occurred: + + + Register + + + Confirm Password + + + Already have an account? + + + Login here + + + Passwords do not match! + + + Registration successful! Redirecting to login... + \ No newline at end of file diff --git a/Views/AuthView/Login.cshtml b/Views/Account/Login.cshtml similarity index 76% rename from Views/AuthView/Login.cshtml rename to Views/Account/Login.cshtml index f660de0..8a06626 100644 --- a/Views/AuthView/Login.cshtml +++ b/Views/Account/Login.cshtml @@ -1,5 +1,8 @@ +@using OneForMe.Services +@inject LocalizationService Localizer + @{ - ViewData["Title"] = "Login"; + ViewData["Title"] = Localizer["Login"]; }
@@ -7,25 +10,25 @@
-

Login

+

@Localizer["Login"]

- +
- +
- +

-

Don't have an account? Register here

+

@Localizer["DontHaveAccount"] @Localizer["RegisterHere"]

@@ -52,16 +55,13 @@ document.getElementById('loginForm').addEventListener('submit', async (e) => { }); if (response.ok) { - messageDiv.innerHTML = '
Login successful! Redirecting...
'; - setTimeout(() => { - window.location.href = '/'; - }, 1500); + window.location.href = '/'; } else { const error = await response.json(); messageDiv.innerHTML = `
${error.message}
`; } } catch (error) { - messageDiv.innerHTML = `
An error occurred: ${error.message}
`; + messageDiv.innerHTML = `
@Localizer["AnErrorOccurred"] ${error.message}
`; } }); \ No newline at end of file diff --git a/Views/AuthView/Register.cshtml b/Views/Account/Register.cshtml similarity index 77% rename from Views/AuthView/Register.cshtml rename to Views/Account/Register.cshtml index 1fdc5c3..8dbe15e 100644 --- a/Views/AuthView/Register.cshtml +++ b/Views/Account/Register.cshtml @@ -1,5 +1,8 @@ +@using OneForMe.Services +@inject LocalizationService Localizer + @{ - ViewData["Title"] = "Register"; + ViewData["Title"] = Localizer["Register"]; }
@@ -7,30 +10,30 @@
-

Register

+

@Localizer["Register"]

- +
- +
- +
- +

-

Already have an account? Login here

+

@Localizer["AlreadyHaveAccount"] @Localizer["LoginHere"]

@@ -49,7 +52,7 @@ document.getElementById('registerForm').addEventListener('submit', async (e) => const messageDiv = document.getElementById('message'); if (password !== confirmPassword) { - messageDiv.innerHTML = '
Passwords do not match!
'; + messageDiv.innerHTML = '
@Localizer["PasswordsDoNotMatch"]
'; return; } @@ -63,9 +66,9 @@ document.getElementById('registerForm').addEventListener('submit', async (e) => }); if (response.ok) { - messageDiv.innerHTML = '
Registration successful! Redirecting to login...
'; + messageDiv.innerHTML = '
@Localizer["RegistrationSuccessful"]
'; setTimeout(() => { - window.location.href = '/AuthView/Login'; + window.location.href = '/Account/Login'; }, 1500); } else { const error = await response.json(); @@ -73,7 +76,7 @@ document.getElementById('registerForm').addEventListener('submit', async (e) => messageDiv.innerHTML = `
${errorMessages}
`; } } catch (error) { - messageDiv.innerHTML = `
An error occurred: ${error.message}
`; + messageDiv.innerHTML = `
@Localizer["AnErrorOccurred"] ${error.message}
`; } }); \ No newline at end of file diff --git a/Views/Home/Dashboard.cshtml b/Views/Home/Dashboard.cshtml index 6ac5c5a..ec4fd82 100644 --- a/Views/Home/Dashboard.cshtml +++ b/Views/Home/Dashboard.cshtml @@ -12,7 +12,7 @@

@Localizer.Get("Welcome")

@Localizer.Get("LoggedInAs"): @User.Identity?.Name

- @Localizer.Get("Logout") + @Localizer.Get("Logout")
@@ -57,7 +57,7 @@
-
@order.CreatorName
+
@order.Name

@Localizer.Get("Code"): @order.OrderCode
@Localizer.Get("Created"): @order.CreatedAt.ToString("MMM dd, yyyy HH:mm")
diff --git a/Views/Order/Create.cshtml b/Views/Order/Create.cshtml index 849d21f..4710207 100644 --- a/Views/Order/Create.cshtml +++ b/Views/Order/Create.cshtml @@ -14,8 +14,8 @@

- - + + @Localizer["GiveOrderName"]
diff --git a/Views/Order/Details.cshtml b/Views/Order/Details.cshtml index 51b94c5..fbac13e 100644 --- a/Views/Order/Details.cshtml +++ b/Views/Order/Details.cshtml @@ -12,7 +12,7 @@
-

@Model.CreatorName

+

@Model.Name

@Localizer.Get("Code"): @Model.OrderCode

@Localizer.Get("CreatedBy"): @Model.CreatorName

@Localizer.Get("Status"): @(Model.IsClosed ? Localizer.Get("Closed") : Localizer.Get("Open"))

diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml index 2bf0f54..0215a2a 100644 --- a/Views/Shared/_Layout.cshtml +++ b/Views/Shared/_Layout.cshtml @@ -23,10 +23,15 @@ + + @if (User.Identity?.IsAuthenticated ?? false) + { + + }