CheckListTemplateHeader törlése WEB-ről

This commit is contained in:
2025-04-25 11:38:09 +02:00
parent 4025224821
commit 2fae17fed4
8 changed files with 172 additions and 20 deletions
@@ -1,5 +1,8 @@
@page
@model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader.CheckListTemplateHeaderPageModel
@using WorkFlowCheck.Common.Helper
@using WorkFlowCheck.Common.DTO
@{
ViewData["Title"] = "Ellenőrzési sablonok";
}
@@ -15,16 +18,16 @@
<thead class="table-primary">
<tr>
<th>ID</th>
<th>Short Name</th>
<th>Description</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.ShortName), typeof(CheckListTemplateHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.Description), typeof(CheckListTemplateHeaderDTO))</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>Short Name</th>
<th>Description</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.ShortName), typeof(CheckListTemplateHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.Description), typeof(CheckListTemplateHeaderDTO))</th>
<th class="text-center">Action</th>
</tr>
</tfoot>
@@ -78,17 +81,7 @@
$('#tbCheckListTemplateHeadersPage').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, './CheckListTemplateHeaderPage?handler=DeleteCheckListTemplateHeader', row.id);
});
</script>
}
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using WorkFlowCheck.Web.Services;
using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
@@ -21,5 +22,10 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
var results = await _checkListService.GetAllCheckListTemplateHeaderAsync();
return new JsonResult(new { data = results });
}
public async Task<JsonResult> OnGetDeleteCheckListTemplateHeader(int id)
{
var isSuccess = await _checkListService.DeleteCheckListTemplateHeader(id);
return new JsonResult(new { result = isSuccess });
}
}
}
@@ -243,6 +243,28 @@ namespace WorkFlowCheck.Web.Services
};
}
}
public async Task<bool> DeleteCheckListTemplateHeader(int id)
{
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/DeleteCheckListTemplateHeader/{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<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
{
@@ -18,7 +18,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeader(int id);
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
Task<bool> DeleteCheckListTemplateHeader(int id);
Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id);
Task<bool> DeleteCheckListTemplateRow(int id);