Felhasználó és szabály törlésének befejezése

This commit is contained in:
2025-04-10 13:37:39 +02:00
parent 7109da0d95
commit cd57fc46bc
16 changed files with 1218 additions and 39 deletions
@@ -26,14 +26,14 @@
<span asp-validation-for="RoleDTO.RoleName" class="text-danger"></span>
</div>
<div class="row">
<div class="col-4">
<div class="col-2">
<div class="mb-3">
<label asp-for="RoleDTO.IsAdmin"></label>
<input type="checkbox" asp-for="RoleDTO.IsAdmin" class="form-check-input" />
<span asp-validation-for="RoleDTO.IsAdmin" class="text-danger"></span>
</div>
</div>
<div class="col-4">
<div class="col-2">
<div class="mb-3">
<label asp-for="RoleDTO.CanDownloadAPK"></label>
<input type="checkbox" asp-for="RoleDTO.CanDownloadAPK" class="form-check-input" />
@@ -47,6 +47,20 @@
<span asp-validation-for="RoleDTO.CanEnableBlocked" class="text-danger"></span>
</div>
</div>
<div class="col-2">
<div class="mb-3">
<label asp-for="RoleDTO.CanUseMobilApp"></label>
<input type="checkbox" asp-for="RoleDTO.CanUseMobilApp" class="form-check-input" />
<span asp-validation-for="RoleDTO.CanUseMobilApp" class="text-danger"></span>
</div>
</div>
<div class="col-2">
<div class="mb-3">
<label asp-for="RoleDTO.CanUseWebAdmin"></label>
<input type="checkbox" asp-for="RoleDTO.CanUseWebAdmin" class="form-check-input" />
<span asp-validation-for="RoleDTO.CanUseWebAdmin" class="text-danger"></span>
</div>
</div>
</div>
<hr class="mt-4 mb-3 border-secondary">
<div class="mb-3 d-flex justify-content-between">
@@ -66,6 +80,8 @@
formData.RoleDTO.IsAdmin = $('#RoleForm input[name="RoleDTO.IsAdmin"]').is(':checked');
formData.RoleDTO.CanDownloadAPK = $('#RoleForm input[name="RoleDTO.CanDownloadAPK"]').is(':checked');
formData.RoleDTO.CanEnableBlocked = $('#RoleForm input[name="RoleDTO.CanEnableBlocked"]').is(':checked');
formData.RoleDTO.CanUseMobilApp = $('#RoleForm input[name="RoleDTO.CanUseMobilApp"]').is(':checked');
formData.RoleDTO.CanUseWebAdmin = $('#RoleForm input[name="RoleDTO.CanUseWebAdmin"]').is(':checked');
if ($form.valid())
{
@@ -23,6 +23,8 @@
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.IsAdmin), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanEnableBlocked), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanDownloadAPK), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanUseMobilApp), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanUseWebAdmin), typeof(RoleDTO))</th>
<th class="text-center">Action</th>
</tr>
</thead>
@@ -34,6 +36,8 @@
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.IsAdmin), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanEnableBlocked), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanDownloadAPK), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanUseMobilApp), typeof(RoleDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanUseWebAdmin), typeof(RoleDTO))</th>
<th>Action</th>
</tr>
</tfoot>
@@ -82,6 +86,25 @@
}
},
{
data: "canUseMobilApp",
searchable: false,
sortable: false,
className: "text-center",
render: function ( data, type, row ) {
return renderCheckBox(data);
}
},
{
data: "canUseWebAdmin",
searchable: false,
sortable: false,
className: "text-center",
render: function ( data, type, row ) {
return renderCheckBox(data);
}
},
{ data: null, render: function (data, type, row) {
return renderActionButtons(row.id);
}}
@@ -92,7 +115,7 @@
"visible": false
},
{
"targets": 6,
"targets": 8,
"className": "text-center",
"width": "10%"
}
@@ -117,17 +140,7 @@
$('#tbRolesPage').on('click', '.delete-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
console.log(row);
showConfirmModal({
title: 'Törlés megerősítése',
message: 'Biztosan törölni szeretnéd ezt az elemet?',
okText: 'Törlés',
cancelText: 'Mégsem'
}).then(function(result) {
if(result === 'ok') {
console.log('Törlés végrehajtva');
}
});
deleteEntity(table, '/UserAndRole/UserRole?handler=DeleteUser', row.id);
});
</script>
}
@@ -21,5 +21,10 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
var results = await _userService.GetAllRoles();
return new JsonResult(new { data = results });
}
public async Task<JsonResult> OnGetDeleteRole(int id)
{
var isSuccess = await _userService.DeleteRole(id);
return new JsonResult(new { result = isSuccess });
}
}
}
@@ -110,17 +110,7 @@
$('#tbUsersPage').on('click', '.delete-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
console.log(row);
showConfirmModal({
title: 'Törlés megerősítése',
message: 'Biztosan törölni szeretnéd ezt az elemet?',
okText: 'Törlés',
cancelText: 'Mégsem'
}).then(function(result) {
if(result === 'ok') {
console.log('Törlés végrehajtva');
}
});
deleteEntity(table, '/UserAndRole/UserPage?handler=DeleteUser', row.id);
});
</script>
}
@@ -22,5 +22,10 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
var results = await _userService.GetAllUsers();
return new JsonResult(new { data = results });
}
public async Task<JsonResult> OnGetDeleteUser(int id)
{
var isSuccess = await _userService.DeleteUser(id);
return new JsonResult(new { result = isSuccess });
}
}
}
@@ -8,10 +8,12 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<List<UserDTO>> GetAllUsers();
Task<ApiResponseDTO<UserDTO>> UpdateUser(UserDTO userDTO);
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
Task<bool> DeleteUser(int id);
Task<RoleDTO> GetRole(int id);
Task<List<RoleDTO>> GetAllRoles();
Task<ApiResponseDTO<RoleDTO>> UpdateRole(RoleDTO roleDTO);
Task<bool> DeleteRole(int id);
Task<UserRoleDTO> GetUserRole(int id);
Task<List<UserRoleDTO>> GetAllUserRoles();
+42 -2
View File
@@ -120,7 +120,27 @@ namespace WorkFlowCheck.Web.Services
};
}
}
public async Task<bool> DeleteUser(int id)
{
string endpoint = $"{_httpClient.BaseAddress}api/User/DeleteUser/{id}";
var retVal = false;
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<bool>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<RoleDTO> GetRole(int id)
{
@@ -192,7 +212,27 @@ namespace WorkFlowCheck.Web.Services
};
}
}
public async Task<bool> DeleteRole(int id)
{
string endpoint = $"{_httpClient.BaseAddress}api/User/DeleteRole/{id}";
var retVal = false;
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<bool>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<UserRoleDTO> GetUserRole(int id)
{
@@ -1,4 +1,5 @@
{
"ApiBaseUrl": "https://localhost:44382/",
"DetailedErrors": true,
"Logging": {
"LogLevel": {