Restore all zeroed views + add bulk gift certificate creation

The HTML entity sweep script had a bug where it wrote empty files for any
view that contained no target Unicode characters, zeroing out 215 view files.
All views restored from the pre-sweep commit (cefdf3e).

Bulk gift certificate feature:
- BulkCreateGiftCertificateDto with Quantity (1-500), Amount, Reason, Expiry, Notes
- GenerateBulkGiftCertificatePdfAsync on IPdfService / PdfService: one Letter page
  per cert, reusing the same purple/gold branded ComposeGiftCertificateContent helper
- GiftCertificatesController: BulkCreate GET/POST, BulkResult GET, BulkDownloadPdf POST
- Views: BulkCreate.cshtml (form with live total preview), BulkResult.cshtml (table +
  Download All PDF button that POSTs cert IDs to avoid URL length limits)
- gift-certificate-bulk.js: live preview + spinner/disable on submit
- Index.cshtml: Bulk Create button added alongside New Certificate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 20:09:22 -04:00
parent 3eda91f170
commit 4ec55e7290
240 changed files with 73116 additions and 0 deletions
@@ -0,0 +1,91 @@
@using PowderCoating.Core.Entities
@model ManufacturerLookupPattern
@{
ViewData["Title"] = "Add Manufacturer Pattern";
}
<div class="container-fluid py-3">
<div class="d-flex align-items-center mb-3">
<a asp-action="Index" class="btn btn-outline-secondary me-3">
<i class="bi bi-arrow-left"></i>
</a>
<h4 class="mb-0"><i class="bi bi-link-45deg me-2 text-primary"></i>Add Manufacturer Pattern</h4>
</div>
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="card border-0 shadow-sm">
<div class="card-body p-4">
<form asp-action="Create" method="post">
@Html.AntiForgeryToken()
<div asp-validation-summary="ModelOnly" class="alert alert-danger alert-permanent mb-3 small"></div>
<div class="mb-3">
<label asp-for="ManufacturerName" class="form-label fw-medium">Manufacturer Name <span class="text-danger">*</span></label>
<input asp-for="ManufacturerName" class="form-control" placeholder="e.g. Prismatic Powders" />
<span asp-validation-for="ManufacturerName" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="Domain" class="form-label fw-medium">Domain</label>
<input asp-for="Domain" class="form-control" placeholder="e.g. prismaticpowders.com" />
<div class="form-text">Used by the AI to match search result URLs to this manufacturer, even when no URL template is configured.</div>
<span asp-validation-for="Domain" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="ProductUrlTemplate" class="form-label fw-medium">Product URL Template</label>
<input asp-for="ProductUrlTemplate" class="form-control" placeholder="e.g. https://www.prismaticpowders.com/shop/powder-coating-colors/{partNumber}/{slug}" />
<div class="form-text">
Supported placeholders:
<code>{partNumber}</code> — manufacturer part number (slashes normalized to hyphens),
<code>{slug}</code> — color name transformed by Slug Transform below,
<code>{colorCode}</code> — color code as-is.
If a required placeholder is missing at runtime the template is skipped and the system falls back to a search URL.
</div>
<span asp-validation-for="ProductUrlTemplate" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="SlugTransform" class="form-label fw-medium">Slug Transform</label>
<select asp-for="SlugTransform" class="form-select">
<option value="LowerHyphen">LowerHyphen — e.g. "jet-black"</option>
<option value="LowerUnderscore">LowerUnderscore — e.g. "jet_black"</option>
<option value="TitleHyphen">TitleHyphen — e.g. "Jet-Black"</option>
<option value="AsIs">AsIs — color name unchanged</option>
</select>
<div class="form-text">How the color name is converted to a URL slug when building the product URL.</div>
<span asp-validation-for="SlugTransform" class="text-danger small"></span>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input asp-for="IsActive" class="form-check-input" type="checkbox" />
<label asp-for="IsActive" class="form-check-label">Active</label>
</div>
<div class="form-text">Inactive patterns are ignored by the AI lookup service.</div>
</div>
<div class="mb-4">
<label asp-for="Notes" class="form-label fw-medium">Notes</label>
<textarea asp-for="Notes" class="form-control" rows="2" placeholder="Optional notes about this pattern or known quirks"></textarea>
<span asp-validation-for="Notes" class="text-danger small"></span>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-lg me-1"></i>Save
</button>
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
@@ -0,0 +1,92 @@
@using PowderCoating.Core.Entities
@model ManufacturerLookupPattern
@{
ViewData["Title"] = "Edit Pattern";
}
<div class="container-fluid py-3">
<div class="d-flex align-items-center mb-3">
<a asp-action="Index" class="btn btn-outline-secondary me-3">
<i class="bi bi-arrow-left"></i>
</a>
<h4 class="mb-0"><i class="bi bi-pencil me-2 text-primary"></i>Edit Pattern</h4>
</div>
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="card border-0 shadow-sm">
<div class="card-body p-4">
<form asp-action="Edit" method="post">
@Html.AntiForgeryToken()
<input asp-for="Id" type="hidden" />
<div asp-validation-summary="ModelOnly" class="alert alert-danger alert-permanent mb-3 small"></div>
<div class="mb-3">
<label asp-for="ManufacturerName" class="form-label fw-medium">Manufacturer Name <span class="text-danger">*</span></label>
<input asp-for="ManufacturerName" class="form-control" placeholder="e.g. Prismatic Powders" />
<span asp-validation-for="ManufacturerName" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="Domain" class="form-label fw-medium">Domain</label>
<input asp-for="Domain" class="form-control" placeholder="e.g. prismaticpowders.com" />
<div class="form-text">Used by the AI to match search result URLs to this manufacturer, even when no URL template is configured.</div>
<span asp-validation-for="Domain" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="ProductUrlTemplate" class="form-label fw-medium">Product URL Template</label>
<input asp-for="ProductUrlTemplate" class="form-control" placeholder="e.g. https://www.prismaticpowders.com/shop/powder-coating-colors/{partNumber}/{slug}" />
<div class="form-text">
Supported placeholders:
<code>{partNumber}</code> — manufacturer part number (slashes normalized to hyphens),
<code>{slug}</code> — color name transformed by Slug Transform below,
<code>{colorCode}</code> — color code as-is.
If a required placeholder is missing at runtime the template is skipped and the system falls back to a search URL.
</div>
<span asp-validation-for="ProductUrlTemplate" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="SlugTransform" class="form-label fw-medium">Slug Transform</label>
<select asp-for="SlugTransform" class="form-select">
<option value="LowerHyphen">LowerHyphen — e.g. "jet-black"</option>
<option value="LowerUnderscore">LowerUnderscore — e.g. "jet_black"</option>
<option value="TitleHyphen">TitleHyphen — e.g. "Jet-Black"</option>
<option value="AsIs">AsIs — color name unchanged</option>
</select>
<div class="form-text">How the color name is converted to a URL slug when building the product URL.</div>
<span asp-validation-for="SlugTransform" class="text-danger small"></span>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input asp-for="IsActive" class="form-check-input" type="checkbox" />
<label asp-for="IsActive" class="form-check-label">Active</label>
</div>
<div class="form-text">Inactive patterns are ignored by the AI lookup service.</div>
</div>
<div class="mb-4">
<label asp-for="Notes" class="form-label fw-medium">Notes</label>
<textarea asp-for="Notes" class="form-control" rows="2" placeholder="Optional notes about this pattern or known quirks"></textarea>
<span asp-validation-for="Notes" class="text-danger small"></span>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-lg me-1"></i>Save Changes
</button>
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
@@ -0,0 +1,215 @@
@using PowderCoating.Core.Entities
@model List<ManufacturerLookupPattern>
@{
ViewData["Title"] = "Manufacturer Lookup Patterns";
}
@section Styles {
<style>
[data-bs-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light td {
background-color: var(--bs-secondary-bg);
color: var(--bs-body-color);
}
[data-bs-theme="dark"] .card {
border-color: var(--bs-border-color) !important;
}
[data-bs-theme="dark"] .card-footer {
background-color: var(--bs-secondary-bg);
border-color: var(--bs-border-color);
}
[data-bs-theme="dark"] code {
color: var(--bs-info);
background-color: transparent;
}
</style>
}
<div class="container-fluid py-3">
<div class="d-flex align-items-center justify-content-between mb-3">
<div>
<h4 class="mb-0"><i class="bi bi-link-45deg me-2 text-primary"></i>Manufacturer Lookup Patterns</h4>
<small class="text-muted">Global URL patterns used by the AI inventory lookup service to build direct product page links.</small>
</div>
<a asp-action="Create" class="btn btn-primary btn-sm">
<i class="bi bi-plus-lg me-1"></i>Add Pattern
</a>
</div>
@if (TempData["Success"] != null)
{
<div class="alert alert-success alert-dismissible mb-3" role="alert">
@TempData["Success"]<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
@if (TempData["Error"] != null)
{
<div class="alert alert-danger alert-dismissible mb-3" role="alert">
@TempData["Error"]<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
<div class="card border-0 shadow-sm">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 small">
<thead class="table-light">
<tr>
<th>Manufacturer Name</th>
<th>Domain</th>
<th>Has URL Template</th>
<th>Slug Transform</th>
<th>Active</th>
<th>Notes</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
@if (!Model.Any())
{
<tr>
<td colspan="7" class="text-center text-muted py-5">
<i class="bi bi-inbox fs-4 d-block mb-2"></i>
No manufacturer lookup patterns configured.
</td>
</tr>
}
@foreach (var p in Model)
{
<tr>
<td class="fw-medium">@p.ManufacturerName</td>
<td>
@if (!string.IsNullOrWhiteSpace(p.Domain))
{
<code class="text-muted small">@p.Domain</code>
}
else
{
<span class="text-muted">—</span>
}
</td>
<td>
@if (!string.IsNullOrWhiteSpace(p.ProductUrlTemplate))
{
<span class="badge bg-success"><i class="bi bi-check-lg me-1"></i>Yes</span>
}
else
{
<span class="badge bg-secondary">No</span>
}
</td>
<td><code class="small">@p.SlugTransform</code></td>
<td>
@if (p.IsActive)
{
<span class="badge bg-success">Active</span>
}
else
{
<span class="badge bg-secondary">Inactive</span>
}
</td>
<td class="text-muted">
@if (!string.IsNullOrWhiteSpace(p.Notes))
{
@(p.Notes.Length > 60 ? p.Notes.Substring(0, 60) + "…" : p.Notes)
}
else
{
<span>—</span>
}
</td>
<td class="text-end">
<a asp-action="Edit" asp-route-id="@p.Id" class="btn btn-outline-secondary btn-sm me-1" title="Edit">
<i class="bi bi-pencil"></i>
</a>
<a asp-action="Delete" asp-route-id="@p.Id" class="btn btn-outline-danger btn-sm" title="Delete">
<i class="bi bi-trash3"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<!-- Mobile card view — shown on screens < 992px -->
@if (Model.Any())
{
<div class="mobile-card-view">
<div class="mobile-card-list">
@foreach (var p in Model)
{
<a href="@Url.Action("Edit", new { id = p.Id })" class="mobile-data-card text-decoration-none">
<div class="mobile-card-header">
<div class="mobile-card-icon @(p.IsActive ? "bg-primary" : "bg-secondary")">
<i class="bi bi-link-45deg"></i>
</div>
<div class="mobile-card-title">
<h6>@p.ManufacturerName</h6>
<small>@(string.IsNullOrWhiteSpace(p.Domain) ? "No domain" : p.Domain)</small>
</div>
</div>
<div class="mobile-card-body">
<div class="mobile-card-row">
<span class="mobile-card-label">Status</span>
<span class="mobile-card-value">
@if (p.IsActive)
{
<span class="badge bg-success">Active</span>
}
else
{
<span class="badge bg-secondary">Inactive</span>
}
</span>
</div>
<div class="mobile-card-row">
<span class="mobile-card-label">URL Template</span>
<span class="mobile-card-value">
@if (!string.IsNullOrWhiteSpace(p.ProductUrlTemplate))
{
<span class="badge bg-success"><i class="bi bi-check-lg me-1"></i>Yes</span>
}
else
{
<span class="badge bg-secondary">No</span>
}
</span>
</div>
@if (!string.IsNullOrWhiteSpace(p.SlugTransform))
{
<div class="mobile-card-row">
<span class="mobile-card-label">Slug Transform</span>
<span class="mobile-card-value"><code class="small">@p.SlugTransform</code></span>
</div>
}
@if (!string.IsNullOrWhiteSpace(p.Notes))
{
<div class="mobile-card-row">
<span class="mobile-card-label">Notes</span>
<span class="mobile-card-value">@(p.Notes.Length > 60 ? p.Notes.Substring(0, 60) + "…" : p.Notes)</span>
</div>
}
</div>
<div class="mobile-card-footer">
<a asp-action="Edit" asp-route-id="@p.Id" class="btn btn-sm btn-outline-secondary me-2">
<i class="bi bi-pencil"></i> Edit
</a>
<a asp-action="Delete" asp-route-id="@p.Id" class="btn btn-sm btn-outline-danger">
<i class="bi bi-trash3"></i> Delete
</a>
</div>
</a>
}
</div>
</div>
}
@if (Model.Any())
{
<div class="card-footer text-muted small">
@Model.Count pattern@(Model.Count == 1 ? "" : "s") &mdash; @Model.Count(p => p.IsActive) active
</div>
}
</div>
</div>