Fix FK violation when publishing a crawled listing without a facility
CI/CD / CI · dotnet build (push) Successful in 1m31s
CI/CD / Deploy · hamkadr (push) Successful in 1m44s

OnPostPublishAsync inserted a Shift/Job with FacilityId=0 when no
facility was selected (e.g. the dropdown is empty because no facilities
exist yet), throwing FK_Shifts_Facilities_FacilityId and surfacing the
production error page.

- Resolve-or-create the facility before insert: use the picked one, else
  create an unverified Facility from a typed name (reusing same-named).
- Guard the role too; on missing facility/role redirect back with a
  Persian error message instead of 500.
- Review form: add "new facility name" input + "— none —" option +
  error alert; add .alert-error style.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-08 07:09:18 +03:30
parent 5f769b0293
commit a2fc70ae57
3 changed files with 63 additions and 2 deletions
+1
View File
@@ -399,6 +399,7 @@ label { font-size: 13px; }
.legal li { margin-bottom: 6px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.alert-success { background: var(--primary-soft); color: var(--primary-dark); }
.alert-error { background: #fdecea; color: #b3261e; border: 1px solid #f5c2c0; }
/* notification bell badge */
.bell-badge { position:absolute; top:-6px; inset-inline-start:-8px; background:var(--accent); color:#fff;