Photo rendberakása + EF migráció

This commit is contained in:
2025-04-02 10:32:27 +02:00
parent fe7b52efde
commit 12bf69aadd
16 changed files with 1913 additions and 19 deletions
@@ -104,7 +104,13 @@
return renderAnswerType(data);
}
},
{ data: "answer" },
{ data: "answer",
searchable: false,
sortable: false,
render: function ( data, type, row ) {
return renderAnswerPhoto(data, row);
}
},
{ data: null, render: function (data, type, row) {
return renderActionButtons(row.id);
}}
@@ -28,7 +28,31 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
public async Task<JsonResult> OnGetLoadCheckListRows(int id)
{
CheckListHeaderDTO = await _checkListService.GetCheckListHeader(id);
return new JsonResult(new { data = CheckListHeaderDTO.CheckListRowDTO });
if (CheckListHeaderDTO.CheckListRowDTO?.Count() > 0)
{
foreach (var item in CheckListHeaderDTO.CheckListRowDTO)
{
if (item.CheckListTemplateRowDTO?.AnswerType == "P")
{
if (item.Photo != null && item.Photo.Length > 0)
{
item.Answer = ConvertToBase64(item.Photo);
}
}
}
}
return new JsonResult(new
{
data = CheckListHeaderDTO.CheckListRowDTO
});
}
public string ConvertToBase64(byte[] photo)
{
if (photo == null || photo.Length == 0)
return string.Empty;
return "data:image/jpeg;base64," + Convert.ToBase64String(photo);
}
}
}
+2 -1
View File
@@ -55,9 +55,10 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
builder.Services.AddFluentValidationSetup();
var app = builder.Build();
string imageDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
//----------------- Munkakönyvtárak létrehozása -----------------------------
string imageDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
if (!Directory.Exists(imageDirectory))
{
Directory.CreateDirectory(imageDirectory);
+6
View File
@@ -192,3 +192,9 @@ function renderAnswerType(data) {
}
return data;
}
function renderAnswerPhoto(data, row) {
if (row.checkListTemplateRowDTO.answerType === 'P') {
return `<img src="${data}" alt="Image" style="height: 100px; width: auto;" />`
}
return data;
}