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
+18 -1
View File
@@ -48,12 +48,29 @@ namespace WorkFlowCheck.BL.Mappings
.ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows));
CreateMap<CheckListRow, CheckListRowDTO>()
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRow));
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRow))
.ForMember(dest => dest.Photo, opt => opt.MapFrom(src => GetImageBytes(src.PhotoFileName)));
CreateMap<RoleCheckListTemplateHeader, RoleCheckListTemplateHeaderDTO>()
.ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.Role))
.ForMember(dest => dest.CheckListTemplateHeaderDTO, opt => opt.MapFrom(src => src.CheckListTemplateHeader));
}
private byte[] GetImageBytes(string fileName)
{
try
{
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "Images", fileName);
if (File.Exists(filePath))
{
return File.ReadAllBytes(filePath);
}
return Array.Empty<byte>(); // Visszaad egy üres byte[]-ot, ha a fájl nem található
}
catch (Exception)
{
return Array.Empty<byte>(); // Hiba esetén is üres byte[]-ot ad vissza
}
}
}
}