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
@@ -278,6 +278,28 @@ namespace WorkFlowCheck.API.Controllers
} }
return retVal; return retVal;
} }
[HttpGet("DeleteCheckListTemplateHeader/{id}")]
public async Task<ApiResponseDTO<bool>> DeleteCheckListTemplateHeader(int id)
{
var retVal = new ApiResponseDTO<bool>()
{
IsSuccess = true,
};
var result = await _checkListService.DeleteCheckListTemplateHeaderAsync(id);
if (result != null)
{
retVal.IsSuccess = true;
retVal.Data = result;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
[HttpGet("GetCheckListTemplateRow/{id}")] [HttpGet("GetCheckListTemplateRow/{id}")]
@@ -50,8 +50,10 @@ namespace WorkFlowCheck.API.Controllers
}; };
try try
{ {
var allowedExtensions = new[] { ".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tiff" };
var imageFolder = Path.Combine(Directory.GetCurrentDirectory(), "Images"); var imageFolder = Path.Combine(Directory.GetCurrentDirectory(), "Images");
var files = Directory.GetFiles(imageFolder) var files = Directory.GetFiles(imageFolder)
.Where(f => allowedExtensions.Contains(Path.GetExtension(f).ToLower()))
.Select(f => .Select(f =>
{ {
var fileInfo = new FileInfo(f); var fileInfo = new FileInfo(f);
@@ -102,8 +104,112 @@ namespace WorkFlowCheck.API.Controllers
}; };
try try
{ {
var imageFolder = Path.Combine(Directory.GetCurrentDirectory(), "PDF"); var pdfFolder = Path.Combine(Directory.GetCurrentDirectory(), "PDF");
var files = Directory.GetFiles(imageFolder) var files = Directory.GetFiles(pdfFolder, "*.pdf")
.Select(f =>
{
var fileInfo = new FileInfo(f);
return new
{
FileName = fileInfo.Name,
FileSize = FormatFileSize(fileInfo.Length),
CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"),
};
});
var checkListFileInfos = new List<ImageFileDTO>();
foreach (var file in files.OrderBy(o => o.FileName).ToList())
{
var checkListFileInfoDTO = new ImageFileDTO()
{
FileName = file.FileName,
FileSize = file.FileSize,
CreateDate = file.CreatedDate,
};
checkListFileInfos.Add(checkListFileInfoDTO);
}
if (checkListFileInfos != null)
{
retVal.IsSuccess = true;
retVal.Data = checkListFileInfos;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
[HttpGet("GetAllLogAuditFiles")]
public async Task<ApiResponseDTO<List<ImageFileDTO>>> GetAllLogAuditiFilesAsync()
{
var retVal = new ApiResponseDTO<List<ImageFileDTO>>()
{
IsSuccess = true,
};
try
{
var logAuditFiles = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\AuditFlow");
var files = Directory.GetFiles(logAuditFiles, "*.log")
.Select(f =>
{
var fileInfo = new FileInfo(f);
return new
{
FileName = fileInfo.Name,
FileSize = FormatFileSize(fileInfo.Length),
CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"),
};
});
var checkListFileInfos = new List<ImageFileDTO>();
foreach (var file in files.OrderBy(o => o.FileName).ToList())
{
var checkListFileInfoDTO = new ImageFileDTO()
{
FileName = file.FileName,
FileSize = file.FileSize,
CreateDate = file.CreatedDate,
};
checkListFileInfos.Add(checkListFileInfoDTO);
}
if (checkListFileInfos != null)
{
retVal.IsSuccess = true;
retVal.Data = checkListFileInfos;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
[HttpGet("GetAllLogBusinessFiles")]
public async Task<ApiResponseDTO<List<ImageFileDTO>>> GetAllLogBusinessFilesAsync()
{
var retVal = new ApiResponseDTO<List<ImageFileDTO>>()
{
IsSuccess = true,
};
try
{
var logBusinessFiles = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\BusinessFlow");
var files = Directory.GetFiles(logBusinessFiles, "*.log")
.Select(f => .Select(f =>
{ {
var fileInfo = new FileInfo(f); var fileInfo = new FileInfo(f);
@@ -489,7 +489,10 @@ namespace WorkFlowCheck.BL.Services
return retVal; return retVal;
} }
public async Task<bool> DeleteCheckListTemplateHeaderAsync(int id)
{
return await DeleteEntityByIdAsync<CheckListTemplateHeader>(id);
}
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id) public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id)
{ {
var retVal = new CheckListTemplateRowDTO(); var retVal = new CheckListTemplateRowDTO();
@@ -19,7 +19,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces
Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeaderAsync(int Id); Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeaderAsync(int Id);
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync(); Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
Task<bool> DeleteCheckListTemplateHeaderAsync(int id);
Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id); Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id);
Task<bool> DeleteCheckListTemplateRowAsync(int id); Task<bool> DeleteCheckListTemplateRowAsync(int id);
Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO); Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO);
@@ -1,5 +1,8 @@
@page @page
@model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader.CheckListTemplateHeaderPageModel @model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader.CheckListTemplateHeaderPageModel
@using WorkFlowCheck.Common.Helper
@using WorkFlowCheck.Common.DTO
@{ @{
ViewData["Title"] = "Ellenőrzési sablonok"; ViewData["Title"] = "Ellenőrzési sablonok";
} }
@@ -15,16 +18,16 @@
<thead class="table-primary"> <thead class="table-primary">
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Short Name</th> <th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.ShortName), typeof(CheckListTemplateHeaderDTO))</th>
<th>Description</th> <th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.Description), typeof(CheckListTemplateHeaderDTO))</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
<tfoot class="table-light"> <tfoot class="table-light">
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Short Name</th> <th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.ShortName), typeof(CheckListTemplateHeaderDTO))</th>
<th>Description</th> <th>@DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.Description), typeof(CheckListTemplateHeaderDTO))</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</tfoot> </tfoot>
@@ -78,17 +81,7 @@
$('#tbCheckListTemplateHeadersPage').on('click', '.delete-btn', function () $('#tbCheckListTemplateHeadersPage').on('click', '.delete-btn', function ()
{ {
const row = table.row($(this).closest('tr')).data(); const row = table.row($(this).closest('tr')).data();
console.log(row); deleteEntity(table, './CheckListTemplateHeaderPage?handler=DeleteCheckListTemplateHeader', row.id);
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');
}
});
}); });
</script> </script>
} }
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using WorkFlowCheck.Web.Services;
using WorkFlowCheck.Web.Services.Interfaces; using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
@@ -21,5 +22,10 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
var results = await _checkListService.GetAllCheckListTemplateHeaderAsync(); var results = await _checkListService.GetAllCheckListTemplateHeaderAsync();
return new JsonResult(new { data = results }); 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) public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
{ {
@@ -18,7 +18,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeader(int id); Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeader(int id);
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync(); Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
Task<bool> DeleteCheckListTemplateHeader(int id);
Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id); Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id);
Task<bool> DeleteCheckListTemplateRow(int id); Task<bool> DeleteCheckListTemplateRow(int id);