+ @* ScriptId is system-generated (SC-…) on create, never operator-supplied —
+ shown read-only when editing an existing script, hidden on the New page. *@
+ @if (!IsNew)
+ {
+
+
+
+
+ }
+
-
-
-
-
-
-
@@ -93,7 +92,6 @@ else
{
ScriptId = _existing.ScriptId,
Name = _existing.Name,
- Language = _existing.Language,
SourceCode = _existing.SourceCode,
RowVersion = _existing.RowVersion,
};
@@ -111,13 +109,13 @@ else
await using var db = await DbFactory.CreateDbContextAsync();
if (IsNew)
{
- if (await db.Scripts.AnyAsync(s => s.ScriptId == _form.ScriptId))
- { _error = $"Script '{_form.ScriptId}' already exists."; return; }
+ // ScriptId is system-generated (mirrors EquipmentId's "EQ-{12 hex}" convention);
+ // Language is always CSharp.
db.Scripts.Add(new Script
{
- ScriptId = _form.ScriptId,
+ ScriptId = $"SC-{Guid.NewGuid().ToString("N")[..12]}",
Name = _form.Name,
- Language = _form.Language,
+ Language = "CSharp",
SourceCode = _form.SourceCode,
SourceHash = sourceHash,
});
@@ -128,7 +126,6 @@ else
if (entity is null) { _error = "Row no longer exists."; return; }
db.Entry(entity).Property(e => e.RowVersion).OriginalValue = _form.RowVersion;
entity.Name = _form.Name;
- entity.Language = _form.Language;
entity.SourceCode = _form.SourceCode;
entity.SourceHash = sourceHash;
}
@@ -164,9 +161,9 @@ else
private sealed class FormModel
{
- [Required, RegularExpression("^[A-Za-z0-9_-]+$")] public string ScriptId { get; set; } = "";
+ // ScriptId is system-generated, display-only (not user-entered) — no validation.
+ public string ScriptId { get; set; } = "";
[Required] public string Name { get; set; } = "";
- [Required] public string Language { get; set; } = "CSharp";
[Required] public string SourceCode { get; set; } = "";
public byte[] RowVersion { get; set; } = [];
}