From 148ea094ce87621e637ad799bf79d5a1a767dfe9 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Fri, 28 Mar 2025 13:56:56 +0100 Subject: [PATCH] =?UTF-8?q?UserRole=20jav=C3=ADt=C3=A1sa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/CheckListHeaderDTO.cs | 6 +- .../DTO/CheckListRowDTO.cs | 2 +- .../DTO/CheckListTemplateHeaderDTO.cs | 2 +- src/WorkFlowCheck.Common/DTO/CheckPointDTO.cs | 2 +- src/WorkFlowCheck.Common/DTO/UserDTO.cs | 2 +- src/WorkFlowCheck.Common/DTO/UserRoleDTO.cs | 4 +- .../Pages/UserAndRole/UserRoleEditPage.cshtml | 104 ++++++++++++++++++ .../UserAndRole/UserRoleEditPage.cshtml.cs | 23 +++- 8 files changed, 135 insertions(+), 10 deletions(-) diff --git a/src/WorkFlowCheck.Common/DTO/CheckListHeaderDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckListHeaderDTO.cs index 58cfb98..b24977b 100644 --- a/src/WorkFlowCheck.Common/DTO/CheckListHeaderDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/CheckListHeaderDTO.cs @@ -10,17 +10,17 @@ namespace WorkFlowCheck.Common.DTO { public int Id { get; set; } public int CheckListTemplateHeaderId { get; set; } - public CheckListTemplateHeaderDTO CheckListTemplateHeaderDTO { get; set; } + public CheckListTemplateHeaderDTO? CheckListTemplateHeaderDTO { get; set; } public DateTime DateExecution { get; set; } public int UserId { get; set; } - public UserDTO UserDTO { get; set; } + public UserDTO? UserDTO { get; set; } public string ShortName { get; set; } = null!; public string Description { get; set; } = null!; public string DocumentNumber { get; set; } = null!; public Guid GuidNumber { get; set; } public bool IsStorno { get; set; } public bool IsEditable { get; set; } - public required ICollection CheckListRowDTO { get; set; } = new List(); + public ICollection? CheckListRowDTO { get; set; } = new List(); public CheckListHeaderDTO() { diff --git a/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs index 8bbdf90..0689cb4 100644 --- a/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs @@ -11,7 +11,7 @@ namespace WorkFlowCheck.Common.DTO public int Id { get; set; } public int CheckListHeaderId { get; set; } public int CheckListTemplateRowId { get; set; } - public CheckListTemplateRowDTO CheckListTemplateRowDTO { get; set; } + public CheckListTemplateRowDTO? CheckListTemplateRowDTO { get; set; } public string GroupName => $"AnswerGroup_{CheckListTemplateRowDTO?.RowIndex ?? 0}"; public string Answer { get; set; } = null!; public bool? AnswerYes { get; set; } = null!; diff --git a/src/WorkFlowCheck.Common/DTO/CheckListTemplateHeaderDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckListTemplateHeaderDTO.cs index 134897e..722048a 100644 --- a/src/WorkFlowCheck.Common/DTO/CheckListTemplateHeaderDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/CheckListTemplateHeaderDTO.cs @@ -8,6 +8,6 @@ namespace WorkFlowCheck.Common.DTO public string ShortName { get; set; } = null!; public string Description { get; set; } = null!; - public required ICollection CheckListTemplateRowDTO { get; set; } = new List(); + public required ICollection? CheckListTemplateRowDTO { get; set; } = new List(); } } diff --git a/src/WorkFlowCheck.Common/DTO/CheckPointDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckPointDTO.cs index df65798..50322a5 100644 --- a/src/WorkFlowCheck.Common/DTO/CheckPointDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/CheckPointDTO.cs @@ -6,6 +6,6 @@ namespace WorkFlowCheck.Common.DTO public int Id { get; set; } public string ShortName { get; set; } public string Code { get; set; } - public List CheckListTemplateRowDTO { get; set; } = new List(); + public List? CheckListTemplateRowDTO { get; set; } = new List(); } } diff --git a/src/WorkFlowCheck.Common/DTO/UserDTO.cs b/src/WorkFlowCheck.Common/DTO/UserDTO.cs index ee83e8a..e076312 100644 --- a/src/WorkFlowCheck.Common/DTO/UserDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/UserDTO.cs @@ -14,6 +14,6 @@ namespace WorkFlowCheck.Common.DTO public string UserName { get;set; } = null!; public string Password { get; set; } public string JwtToken { get; set; } = null!; - public required ICollection RoleDTO { get; set; } = new List(); + public ICollection? RoleDTO { get; set; } = new List(); } } diff --git a/src/WorkFlowCheck.Common/DTO/UserRoleDTO.cs b/src/WorkFlowCheck.Common/DTO/UserRoleDTO.cs index 56ab73b..92c8523 100644 --- a/src/WorkFlowCheck.Common/DTO/UserRoleDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/UserRoleDTO.cs @@ -11,9 +11,9 @@ namespace WorkFlowCheck.Common.DTO { public int Id { get; set; } public int? RoleId { get; set; } = 0; - public RoleDTO RoleDTO { get; set; } + public RoleDTO? RoleDTO { get; set; } public int UserId { get; set; } - public UserDTO UserDTO { get; set; } + public UserDTO? UserDTO { get; set; } } } diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml index f6abcf7..ea147dd 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml @@ -1,4 +1,108 @@ @page @model WorkFlowCheck.Web.Pages.UserAndRole.UserRoleEditPageModel +@using Microsoft.AspNetCore.Antiforgery +@inject IAntiforgery Antiforgery @{ + ViewData["Title"] = "Ellenőrzési pont"; + var UserRoleId = Model.UserRoleDTO.Id; + var urlPost = Url.Page("./UserRoleEditPage", "Save"); +} +

@ViewData["Title"]

+ + + +
+
+ + +
+
+ + + +
+
+ + + +
+
+
+ + +
+
+
+ +@section Scripts { + } diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml.cs index c036ac4..3b36387 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/UserRoleEditPage.cshtml.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.Rendering; using Serilog; using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Web.Services.Interfaces; @@ -13,7 +14,11 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole [BindProperty] public UserRoleDTO UserRoleDTO { get; set; } - + [BindProperty] + public List Roles { get; set; } + [BindProperty] + public List Users { get; set; } + public UserRoleEditPageModel(ILogger logger, IUserService userService) { _logger = logger; @@ -22,6 +27,7 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole public async Task OnGet(int id) { + await InitSelectItems(); UserRoleDTO = await _userService.GetUserRole(id); } public async Task OnPostSave([FromBody] UserRoleDTO userRoleDTO) @@ -45,5 +51,20 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole return new JsonResult(new { success = false }); } + private async Task InitSelectItems() + { + var roles = await _userService.GetAllRoles(); + this.Roles = new List(); + foreach (var role in roles) + { + this.Roles.Add(new SelectListItem() { Value = role.Id.ToString(), Text = role.RoleName }); + } + var users = await _userService.GetAllUsers(); + this.Users = new List(); + foreach (var user in users) + { + this.Users.Add(new SelectListItem() { Value = user.Id.ToString(), Text = user.UserName }); + } + } } }