Fix FK violation when publishing a crawled listing without a facility
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:
@@ -10,6 +10,10 @@
|
||||
</div>
|
||||
|
||||
<div class="container section">
|
||||
@if (Model.Error is not null)
|
||||
{
|
||||
<div class="alert alert-error" style="margin-bottom:16px;">⚠ @Model.Error</div>
|
||||
}
|
||||
<div class="detail-grid">
|
||||
<div>
|
||||
<div class="card card-pad">
|
||||
@@ -47,11 +51,14 @@
|
||||
<div class="filter-group">
|
||||
<label>مرکز درمانی</label>
|
||||
<select name="FacilityId">
|
||||
<option value="0">— انتخاب نشده —</option>
|
||||
@foreach (var f in Model.Facilities)
|
||||
{
|
||||
<option value="@f.Id">@f.Name — @f.City?.Name</option>
|
||||
}
|
||||
</select>
|
||||
<input type="text" name="NewFacilityName" placeholder="یا نام مرکز جدید را وارد کن…" style="margin-top:6px;" />
|
||||
<p class="muted" style="font-size:11px; margin:4px 0 0;">اگر مرکز در فهرست نیست، نامش را اینجا بنویس تا بهصورت «تأییدنشده» ساخته شود.</p>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label>نقش</label>
|
||||
|
||||
Reference in New Issue
Block a user