fix(documents): bind submitted CV captures to their saved revision
This commit is contained in:
@@ -72,7 +72,16 @@ public sealed class SubmittedApplicationPackageService : ISubmittedApplicationPa
|
||||
? (await variantQuery.ToListAsync(ct)).MaxBy(v => v.UpdatedAtUtc)
|
||||
: await variantQuery.OrderByDescending(v => v.UpdatedAtUtc).FirstOrDefaultAsync(ct);
|
||||
var profile = await _db.CareerProfiles.AsNoTracking().FirstOrDefaultAsync(p => p.OwnerUserId == ownerUserId, ct);
|
||||
var render = variant is null ? null : await _variants.RenderAsync(ownerUserId, variant.Id, person, ct);
|
||||
var render = variant is null ? null : await _variants.RenderAsync(ownerUserId, variant.Id, person, ct, variant.Version > 0 ? variant.Version : null);
|
||||
if (variant is not null)
|
||||
{
|
||||
// Legacy version-zero variants remain capturable; recheck the stored snapshot after rendering.
|
||||
var current = await _db.CvVariants.AsNoTracking()
|
||||
.Where(v => v.Id == variant.Id && v.OwnerUserId == ownerUserId)
|
||||
.Select(v => new { v.Version, v.SettingsJson }).SingleOrDefaultAsync(ct);
|
||||
if (render is null || current is null || current.Version != variant.Version || current.SettingsJson != variant.SettingsJson)
|
||||
throw new DbUpdateConcurrencyException("The selected CV changed before the submitted package could be captured.");
|
||||
}
|
||||
var version = (await _db.SubmittedApplicationPackages.AsNoTracking()
|
||||
.Where(x => x.OwnerUserId == ownerUserId && x.JobApplicationId == jobApplicationId)
|
||||
.Select(x => (int?)x.Version)
|
||||
|
||||
Reference in New Issue
Block a user