Fix FK violation on kiosk intake submission: set JobPriorityId
ProcessSubmissionAsync was creating a Job without JobPriorityId, leaving it as 0 which violates the FK to JobPriorityLookups. Look up the NORMAL priority the same way JobsController does everywhere else. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -586,10 +586,13 @@ public class KioskController : Controller
|
|||||||
: "RemoteIntake";
|
: "RemoteIntake";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Create Job in Pending status
|
// 3. Create Job in Pending status with Normal priority
|
||||||
var statuses = await _lookupCache.GetJobStatusLookupsAsync(companyId);
|
var statuses = await _lookupCache.GetJobStatusLookupsAsync(companyId);
|
||||||
var pendingStatus = statuses.FirstOrDefault(s => s.StatusCode == AppConstants.StatusCodes.Job.Pending);
|
var pendingStatus = statuses.FirstOrDefault(s => s.StatusCode == AppConstants.StatusCodes.Job.Pending);
|
||||||
|
|
||||||
|
var priorities = await _lookupCache.GetJobPriorityLookupsAsync(companyId);
|
||||||
|
var normalPriority = priorities.FirstOrDefault(p => p.PriorityCode == "NORMAL") ?? priorities.FirstOrDefault();
|
||||||
|
|
||||||
var jobNumber = await GenerateJobNumberAsync(companyId);
|
var jobNumber = await GenerateJobNumberAsync(companyId);
|
||||||
var job = new Job
|
var job = new Job
|
||||||
{
|
{
|
||||||
@@ -597,6 +600,7 @@ public class KioskController : Controller
|
|||||||
CustomerId = customer!.Id,
|
CustomerId = customer!.Id,
|
||||||
JobNumber = jobNumber,
|
JobNumber = jobNumber,
|
||||||
JobStatusId = pendingStatus?.Id ?? 1,
|
JobStatusId = pendingStatus?.Id ?? 1,
|
||||||
|
JobPriorityId = normalPriority?.Id ?? 1,
|
||||||
SpecialInstructions = session.JobDescription,
|
SpecialInstructions = session.JobDescription,
|
||||||
Description = $"Walk-in intake — {session.CustomerFirstName} {session.CustomerLastName}".Trim()
|
Description = $"Walk-in intake — {session.CustomerFirstName} {session.CustomerLastName}".Trim()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user