From 3e1701cfdf616af91f51b241caaa59ff4b8f7d88 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 25 Jun 2025 14:54:38 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20=E0=B8=AA=E0=B8=A1=E0=B8=B1=E0=B8=84?= =?UTF-8?q?=E0=B8=A3=E0=B8=AA=E0=B8=AD=E0=B8=9A=E0=B8=84=E0=B8=B1=E0=B8=94?= =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B8=AD=E0=B8=81=20=E0=B8=96?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=AD=E0=B8=B1=E0=B8=9B=E0=B8=A3=E0=B8=B9?= =?UTF-8?q?=E0=B8=9B=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B8=88=E0=B8=B0=E0=B9=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=87=20error=20#1377?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/CandidateService.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index f0e7e9e..ae41bb6 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -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);