fix(documents): bind submitted CV captures to their saved revision
This commit is contained in:
@@ -148,8 +148,15 @@ public sealed class ApplicationAssetsController : ControllerBase
|
||||
{
|
||||
var user = await _users.GetUserAsync(User);
|
||||
if (user is null) return Unauthorized();
|
||||
var result = await _packages.CaptureAsync(user.Id, jobId, Person(user), ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
try
|
||||
{
|
||||
var result = await _packages.CaptureAsync(user.Id, jobId, Person(user), ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
return Conflict(new { code = "revision_conflict", message = "The application documents changed. Reload and review them before capturing a submitted package." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("submitted-packages/{packageId:int}")]
|
||||
|
||||
@@ -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