From 20d7ceb78478f1b1d44e5cedb30774754cef861a Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sat, 25 Oct 2025 16:20:17 +0200 Subject: [PATCH 1/2] Implemented frontend Locations update buttons --- src/Controllers/LocationsController.cs | 2 +- src/Models/LocationsModels.cs | 4 + src/Models/LocationsRequestModels.cs | 4 + src/Views/Home/Locations.cshtml | 153 ++++++++++++++++++++++++- 4 files changed, 160 insertions(+), 3 deletions(-) diff --git a/src/Controllers/LocationsController.cs b/src/Controllers/LocationsController.cs index aab535a..ff58718 100644 --- a/src/Controllers/LocationsController.cs +++ b/src/Controllers/LocationsController.cs @@ -67,7 +67,7 @@ public class LocationsController : Controller } [HttpPost("Update")] - public async Task Update(LocationsModifyRequestModel requestModel) + public async Task Update([FromBody]LocationsModifyRequestModel requestModel) { if (requestModel is null) { diff --git a/src/Models/LocationsModels.cs b/src/Models/LocationsModels.cs index 048d03d..1a8501f 100644 --- a/src/Models/LocationsModels.cs +++ b/src/Models/LocationsModels.cs @@ -1,6 +1,7 @@ namespace Berufsschule_HAM.Models; using System.Text.Json; +using System.Text.Json.Serialization; using Berufsschule_HAM.Exceptions; public class LocationModel { @@ -22,8 +23,11 @@ public class LocationModel } public class LocationsDescription { + [JsonPropertyName("Location")] public string? Location { get; set; } + [JsonPropertyName("RoomNumber")] public string? RoomNumber { get; set; } + [JsonPropertyName("Seat")] public string? Seat { get; set; } } diff --git a/src/Models/LocationsRequestModels.cs b/src/Models/LocationsRequestModels.cs index 141c1d2..501c25d 100644 --- a/src/Models/LocationsRequestModels.cs +++ b/src/Models/LocationsRequestModels.cs @@ -1,3 +1,5 @@ +using System.Text.Json.Serialization; + namespace Berufsschule_HAM.Models; public class LocationsCreateRequestModel @@ -7,7 +9,9 @@ public class LocationsCreateRequestModel public class LocationsModifyRequestModel { + [JsonPropertyName("Location")] public required string Location { get; set; } + [JsonPropertyName("Description")] public required LocationsDescription Description { get; set; } } diff --git a/src/Views/Home/Locations.cshtml b/src/Views/Home/Locations.cshtml index e36a0b6..bf4c5ee 100644 --- a/src/Views/Home/Locations.cshtml +++ b/src/Views/Home/Locations.cshtml @@ -38,12 +38,20 @@ @locationTableViewModel.Seat
- +
@@ -77,6 +85,35 @@ + + + + + + + \ No newline at end of file From 0929e2c6387b45e0c9d22c0abe8c8d2a85b076d4 Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sat, 25 Oct 2025 16:40:18 +0200 Subject: [PATCH 2/2] Implemented frontent Locations create button, fixed localization for frontend Locations --- src/Controllers/LocationsController.cs | 4 +- src/Models/LocationsRequestModels.cs | 1 + src/Resources/Views.Home.Locations.de.resx | 42 +++++ src/Views/Home/Locations.cshtml | 171 ++++++++++++++++----- 4 files changed, 176 insertions(+), 42 deletions(-) diff --git a/src/Controllers/LocationsController.cs b/src/Controllers/LocationsController.cs index ff58718..02e62e9 100644 --- a/src/Controllers/LocationsController.cs +++ b/src/Controllers/LocationsController.cs @@ -26,8 +26,8 @@ public class LocationsController : Controller return list; } - [HttpGet("Create")] - public async Task Create(LocationsCreateRequestModel model) + [HttpPost("Create")] + public async Task Create([FromBody]LocationsCreateRequestModel model) { try { diff --git a/src/Models/LocationsRequestModels.cs b/src/Models/LocationsRequestModels.cs index 501c25d..522913e 100644 --- a/src/Models/LocationsRequestModels.cs +++ b/src/Models/LocationsRequestModels.cs @@ -4,6 +4,7 @@ namespace Berufsschule_HAM.Models; public class LocationsCreateRequestModel { + [JsonPropertyName("Description")] public required LocationsDescription LocationsDescription { get; set; } } diff --git a/src/Resources/Views.Home.Locations.de.resx b/src/Resources/Views.Home.Locations.de.resx index 823228c..c8db175 100644 --- a/src/Resources/Views.Home.Locations.de.resx +++ b/src/Resources/Views.Home.Locations.de.resx @@ -19,4 +19,46 @@ Ort anlegen + + Ort ID + + + Ort Name + + + Raumnummer + + + Sitz + + + Aktion + + + Anpassen + + + Löschen + + + Ort erfolgreich gelöscht + + + Unbekannter Fehler + + + Server konnte nicht erreicht werden + + + Ort wurde erfolgreich angepasst + + + Ort konnte nicht angepasst werden + + + Ort wurde erfolgreich erstellt + + + Erstellung des Ortes ist fehlgeschlagen + diff --git a/src/Views/Home/Locations.cshtml b/src/Views/Home/Locations.cshtml index bf4c5ee..73ddb16 100644 --- a/src/Views/Home/Locations.cshtml +++ b/src/Views/Home/Locations.cshtml @@ -12,7 +12,7 @@
- +
@@ -20,11 +20,11 @@ - - - - - + + + + + @@ -45,13 +45,13 @@ data-seat="@locationTableViewModel.Seat" data-bs-toggle="modal" data-bs-target="#editModal"> - Edit + @T["Edit"] @@ -161,41 +161,15 @@ row.classList.add('table-danger'); setTimeout(() => row.remove(), 300); - showToast('Location deleted successfully', 'success'); + showToast('@T["Location deleted successfully"]', 'success'); } else { - showToast(`❌ ${result.reason}: ${result.exception || 'Unknown error'}`, 'danger'); + showToast(`${result.reason}: ${result.exception || '@T["Unknown error"]'}`, 'danger'); } } catch (error) { console.error(error); - showToast('Error contacting server', 'danger'); + showToast('@T["Error contacting server"]', 'danger'); } }); - - // Simple toast helper - function showToast(message, type) { - const toastContainer = document.getElementById('toastContainer') || createToastContainer(); - const toast = document.createElement('div'); - toast.className = `toast align-items-center text-white bg-${type} border-0`; - toast.role = 'alert'; - toast.innerHTML = ` -
-
${message}
- -
- `; - toastContainer.appendChild(toast); - const bsToast = new bootstrap.Toast(toast, { delay: 3000 }); - bsToast.show(); - toast.addEventListener('hidden.bs.toast', () => toast.remove()); - } - - function createToastContainer() { - const container = document.createElement('div'); - container.id = 'toastContainer'; - container.className = 'toast-container position-fixed bottom-0 end-0 p-3'; - document.body.appendChild(container); - return container; - } }); @@ -299,13 +273,130 @@ // Close modal bootstrap.Modal.getInstance(editModal).hide(); - showToast('Location updated successfully', 'success'); + showToast('@T["Location updated successfully"]', 'success'); } else { - showToast(`${result.reason || 'Update failed'}`, 'danger'); + showToast(`${result.reason || '@T["Location update failed"]'}`, 'danger'); } } catch (error) { console.error(error); - showToast('Error contacting server', 'danger'); + showToast('@T["Error contacting server"]', 'danger'); + } + }); + }); + + + + + +
UserAsset IDAsset NameLocationAction@T["Location ID"]@T["Location name"]@T["Room number"]@T["Seat"]@T["Action"]