fix minio file
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s

This commit is contained in:
Suphonchai Phoonsawat 2026-05-19 16:57:33 +07:00
parent e8681834f2
commit 13a8e309e7

View file

@ -596,12 +596,11 @@ public class ImportBackgroundService : BackgroundService
});
historyEntry.Property("RecruitImportId").CurrentValue = rec_import_id;
// get doc from minio
// get doc from minio (MinIOService already saves Document to its own context)
var doc = await _minioService.UploadFileAsync(new DummyFormFile(job.ImportFile));
var imported = new ScoreImport();
imported.Year = rec_import_year;
imported.RecruitImportId = rec_import_id;
imported.ImportFile = doc;
imported.CreatedAt = DateTime.Now;
imported.CreatedUserId = job.UserId ?? "";
imported.CreatedFullName = job.FullName ?? "System Administrator";
@ -610,8 +609,9 @@ public class ImportBackgroundService : BackgroundService
imported.LastUpdateFullName = job.FullName ?? "System Administrator";
imported.Scores = new List<RecruitScore>();
// Save ScoreImport parent first to get its Id
_context.ScoreImports.Add(imported);
// Save ScoreImport — use shadow FK for ImportFile to avoid re-inserting Document
var scoreEntry = _context.ScoreImports.Add(imported);
scoreEntry.Property("ImportFileId").CurrentValue = doc.Id;
await _context.SaveChangesAsync();
_context.ChangeTracker.Clear();