From 9297ff39705f91e0ab0d0271f74372c0db97e4f0 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Tue, 18 Mar 2025 13:12:17 +0100 Subject: [PATCH] =?UTF-8?q?Bootstrap=20Icon=20hozz=C3=A1ad=C3=A1sa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WorkFlowCheck.BL/Services/UserService.cs | 19 +++- .../CheckPoints/CheckPointEditPage.cshtml | 6 +- .../CheckPoints/CheckPointsPage.cshtml | 6 +- .../Equipments/EquipmentsPage.cshtml | 6 +- .../BaseStock/Locations/LocationsPage.cshtml | 6 +- .../Pages/Shared/_Layout.cshtml | 10 ++- .../Pages/UserAndRole/RoleEditPage.cshtml | 87 +++++++++++++++++++ .../Pages/UserAndRole/RoleEditPage.cshtml.cs | 39 ++++++++- .../Pages/UserAndRole/RolePage.cshtml | 10 +-- .../Pages/UserAndRole/UserEditPage.cshtml | 42 ++++----- .../Pages/UserAndRole/UserEditPage.cshtml.cs | 4 +- .../Pages/UserAndRole/UserPage.cshtml | 6 +- src/WorkFlowCheck.Web/Services/UserService.cs | 2 +- src/WorkFlowCheck.Web/wwwroot/js/site.js | 11 +++ 14 files changed, 202 insertions(+), 52 deletions(-) diff --git a/src/WorkFlowCheck.BL/Services/UserService.cs b/src/WorkFlowCheck.BL/Services/UserService.cs index 25b4ed3..1e6bb9d 100644 --- a/src/WorkFlowCheck.BL/Services/UserService.cs +++ b/src/WorkFlowCheck.BL/Services/UserService.cs @@ -189,7 +189,24 @@ namespace WorkFlowCheck.BL.Services return retVal; } - public async Task GetRoleAsync(int Id) => throw new NotImplementedException(); + public async Task GetRoleAsync(int Id) + { + var retVal = new RoleDTO(); + + try + { + var user = await _dbContext.Roles.Where(w => w.Id == Id).FirstOrDefaultAsync(); + if (user != null) + { + retVal = _mapper.Map(user); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } public async Task> GetAllRoleAsync() { var retVal = new List(); diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml index 8ac1e60..254580d 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml @@ -74,9 +74,7 @@ { data: "operationDescription" }, { data: "answerType" }, { data: null, render: function (data, type, row) { - return ` - - `; + return renderActionButtons(row.id); }} ], columnDefs: [ @@ -87,7 +85,7 @@ { "targets": 4, "className": "text-center", - "width": "15%" + "width": "10%" } ], diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointsPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointsPage.cshtml index f4ace41..1fd7f78 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointsPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointsPage.cshtml @@ -44,9 +44,7 @@ { data: "shortName" }, { data: "code" }, { data: null, render: function (data, type, row) { - return ` - - `; + return renderActionButtons(row.id); }} ], columnDefs: [ @@ -57,7 +55,7 @@ { "targets": 3, "className": "text-center", - "width": "15%" + "width": "10%" } ], diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Equipments/EquipmentsPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Equipments/EquipmentsPage.cshtml index 927e952..5c7a0ef 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Equipments/EquipmentsPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Equipments/EquipmentsPage.cshtml @@ -39,9 +39,7 @@ { data: "id" }, { data: "shortName" }, { data: null, render: function (data, type, row) { - return ` - - `; + return renderActionButtons(row.id); }} ], columnDefs: [ @@ -52,7 +50,7 @@ { "targets": 2, "className": "text-center", - "width": "15%" + "width": "10" } ], diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml index 5663bbd..4c9c519 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml @@ -39,9 +39,7 @@ { data: "id" }, { data: "fullName" }, { data: null, render: function (data, type, row) { - return ` - - `; + return renderActionButtons(row.id); }} ], columnDefs: [ @@ -52,7 +50,7 @@ { "targets": 2, "className": "text-center", - "width": "15%" + "width": "10%" } ], diff --git a/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml b/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml index e2ab197..c305adb 100644 --- a/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml +++ b/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml @@ -8,6 +8,7 @@ +
@@ -60,7 +61,9 @@ @@ -147,5 +150,10 @@ @await RenderSectionAsync("Scripts", required: false) + \ No newline at end of file diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml index ab5b744..cbf6fd4 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml @@ -1,4 +1,91 @@ @page @model WorkFlowCheck.Web.Pages.UserAndRole.RoleEditPageModel +@using Microsoft.AspNetCore.Antiforgery +@inject IAntiforgery Antiforgery @{ + ViewData["Title"] = "Ellenőrzési pont"; + var RoleId = Model.RoleDTO.Id; + var urlPost = Url.Page("./RoleEditPage", "Save"); +} +

@ViewData["Title"]

+ + + +
+
+ + +
+ + + +
+
+ + +
+
+
+ +@section Scripts { + } diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml.cs index 451a9f0..def4308 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/RoleEditPage.cshtml.cs @@ -1,12 +1,49 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Serilog; +using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Pages.UserAndRole { public class RoleEditPageModel : PageModel { - public void OnGet() + private readonly ILogger _logger; + private readonly IUserService _userService; + + [BindProperty] + public RoleDTO RoleDTO { get; set; } + + public RoleEditPageModel(ILogger logger, IUserService userService) { + _userService = userService; + _logger = logger; + } + + public async Task OnGet(int id) + { + RoleDTO = await _userService.GetRole(id); + } + public async Task OnPostSave([FromBody] RoleDTO roleDTO) + { + try + { + var result = await _userService.UpdateRole(roleDTO); + if (result.IsSuccess) + { + return new JsonResult(new { success = true }); + } + else + { + return new JsonResult(new { success = false }); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + + return new JsonResult(new { success = false }); } } } diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml b/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml index 2179e76..9d75862 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml @@ -7,7 +7,9 @@
- +
@@ -39,9 +41,7 @@ { data: "id" }, { data: "roleName" }, { data: null, render: function (data, type, row) { - return ` - - `; + return renderActionButtons(row.id); }} ], columnDefs: [ @@ -52,7 +52,7 @@ { "targets": 2, "className": "text-center", - "width": "15%" + "width": "10%" } ], diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml index 0e48aa6..d749b2d 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml @@ -4,7 +4,7 @@ @inject IAntiforgery Antiforgery @{ ViewData["Title"] = "Ellenőrzési pont"; - var UserId = Model.User.Id; + var UserId = Model.UserDTO.Id; var urlPost = Url.Page("./UserEditPage", "Save"); }

@ViewData["Title"]

@@ -14,37 +14,37 @@
- - - - + + + +
- - - + + +
- @if (Model.User.Id == 0) + @if (Model.UserDTO.Id == 0) {
- - - + + +
}
- - - + + +
- - - + + +
- - - + + +
diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml.cs index 0ca918b..2cfb0a0 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserEditPage.cshtml.cs @@ -13,7 +13,7 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole private readonly IUserService _userService; [BindProperty] - public UserDTO User { get; set; } + public UserDTO UserDTO { get; set; } public UserEditPageModel(ILogger logger, IUserService userService) { @@ -23,7 +23,7 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole public async Task OnGet(int id) { - User = await _userService.GetUser(id); + UserDTO = await _userService.GetUser(id); } public async Task OnPostSave([FromBody] UserDTO userDTO) { diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserPage.cshtml b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserPage.cshtml index 8ed3b72..5d0d1e6 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserPage.cshtml @@ -48,9 +48,7 @@ { data: "userName" }, { data: "email" }, { data: null, render: function (data, type, row) { - return ` - - `; + return renderActionButtons(row.id); }} ], columnDefs: [ @@ -61,7 +59,7 @@ { "targets": 5, "className": "text-center", - "width": "15%" + "width": "10%" } ], diff --git a/src/WorkFlowCheck.Web/Services/UserService.cs b/src/WorkFlowCheck.Web/Services/UserService.cs index 9ebf2c8..ff54fcd 100644 --- a/src/WorkFlowCheck.Web/Services/UserService.cs +++ b/src/WorkFlowCheck.Web/Services/UserService.cs @@ -124,7 +124,7 @@ namespace WorkFlowCheck.Web.Services public async Task GetRole(int id) { - string endpoint = $"{_httpClient.BaseAddress}api/Role/GetRole/{id}"; + string endpoint = $"{_httpClient.BaseAddress}api/User/GetRole/{id}"; var retVal = new RoleDTO(); try { diff --git a/src/WorkFlowCheck.Web/wwwroot/js/site.js b/src/WorkFlowCheck.Web/wwwroot/js/site.js index f5f973c..2c363db 100644 --- a/src/WorkFlowCheck.Web/wwwroot/js/site.js +++ b/src/WorkFlowCheck.Web/wwwroot/js/site.js @@ -94,3 +94,14 @@ function showMessageModal(options) { }); modal.show(); } + +function renderActionButtons(rowId) { + return ` + + + `; +}