Fix สมัครสอบคัดเลือก ถ้าอัปรูปแก้ไขระบบจะแจ้ง error #1377

This commit is contained in:
Bright 2025-06-25 14:54:38 +07:00
parent 2d694c79fc
commit 3e1701cfdf

View file

@ -1259,9 +1259,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate == null)
throw new Exception(GlobalMessages.ExamNotFound);
string profileImgId = candidate.ProfileImg.Id.ToString();
if (candidate.ProfileImg != null)
{
await DeleteDocument(candidate.ProfileImg.Id.ToString());
//ลบ FK ในเบสก่อนแล้วค่อยไปลบที่ minIo
candidate.ProfileImg = null;
await _context.SaveChangesAsync();
await DeleteDocument(profileImgId);
}
var doc = await _minioService.UploadFileAsync(file);
@ -1282,9 +1286,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate == null)
throw new Exception(GlobalMessages.ExamNotFound);
string profileImgId = candidate.ProfileImg.Id.ToString();
if (candidate.ProfileImg != null)
{
await DeleteDocument(candidate.ProfileImg.Id.ToString());
//ลบ FK ในเบสก่อนแล้วค่อยไปลบที่ minIo
candidate.ProfileImg = null;
await _context.SaveChangesAsync();
await DeleteDocument(profileImgId);
}
var doc = await _minioService.UploadFileAsync(file);