update model and fix code
All checks were successful
Build & Deploy on Dev / build (push) Successful in 44s

This commit is contained in:
Suphonchai Phoonsawat 2026-05-19 17:14:39 +07:00
parent 9c353f40c6
commit 054ef81c63
3 changed files with 10 additions and 6 deletions

View file

@ -615,9 +615,9 @@ public class ImportBackgroundService : BackgroundService
imported.LastUpdateFullName = job.FullName ?? "System Administrator";
imported.Scores = new List<RecruitScore>();
// Save ScoreImport — use shadow FK for ImportFile to avoid re-inserting Document
var scoreEntry = _context.ScoreImports.Add(imported);
scoreEntry.Property("ImportFileId").CurrentValue = doc.Id;
// Save ScoreImport — set ImportFileId FK directly (explicit property, not shadow)
imported.ImportFileId = doc.Id;
_context.ScoreImports.Add(imported);
await _context.SaveChangesAsync();
_context.ChangeTracker.Clear();
@ -713,7 +713,7 @@ public class ImportBackgroundService : BackgroundService
// Set ScoreImportId FK for all scores in batch
foreach (var score in batchScores)
{
_context.Entry(score).Property("ScoreImportId").CurrentValue = scoreImport_id;
score.ScoreImportId = scoreImport_id;
}
await _context.BulkInsertAsync(batchScores);
batchScores.Clear();
@ -727,7 +727,7 @@ public class ImportBackgroundService : BackgroundService
{
foreach (var score in batchScores)
{
_context.Entry(score).Property("ScoreImportId").CurrentValue = scoreImport_id;
score.ScoreImportId = scoreImport_id;
}
await _context.BulkInsertAsync(batchScores);
}