This commit is contained in:
parent
e8681834f2
commit
13a8e309e7
1 changed files with 4 additions and 4 deletions
|
|
@ -596,12 +596,11 @@ public class ImportBackgroundService : BackgroundService
|
||||||
});
|
});
|
||||||
historyEntry.Property("RecruitImportId").CurrentValue = rec_import_id;
|
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 doc = await _minioService.UploadFileAsync(new DummyFormFile(job.ImportFile));
|
||||||
var imported = new ScoreImport();
|
var imported = new ScoreImport();
|
||||||
imported.Year = rec_import_year;
|
imported.Year = rec_import_year;
|
||||||
imported.RecruitImportId = rec_import_id;
|
imported.RecruitImportId = rec_import_id;
|
||||||
imported.ImportFile = doc;
|
|
||||||
imported.CreatedAt = DateTime.Now;
|
imported.CreatedAt = DateTime.Now;
|
||||||
imported.CreatedUserId = job.UserId ?? "";
|
imported.CreatedUserId = job.UserId ?? "";
|
||||||
imported.CreatedFullName = job.FullName ?? "System Administrator";
|
imported.CreatedFullName = job.FullName ?? "System Administrator";
|
||||||
|
|
@ -610,8 +609,9 @@ public class ImportBackgroundService : BackgroundService
|
||||||
imported.LastUpdateFullName = job.FullName ?? "System Administrator";
|
imported.LastUpdateFullName = job.FullName ?? "System Administrator";
|
||||||
imported.Scores = new List<RecruitScore>();
|
imported.Scores = new List<RecruitScore>();
|
||||||
|
|
||||||
// Save ScoreImport parent first to get its Id
|
// Save ScoreImport — use shadow FK for ImportFile to avoid re-inserting Document
|
||||||
_context.ScoreImports.Add(imported);
|
var scoreEntry = _context.ScoreImports.Add(imported);
|
||||||
|
scoreEntry.Property("ImportFileId").CurrentValue = doc.Id;
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
_context.ChangeTracker.Clear();
|
_context.ChangeTracker.Clear();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue