Blazor dialog adding entity

From IntentArchitect/Intent.Modules.NET · View interactive version

Blazor dialog adding entity is an AI agent skill from the GitHub repository IntentArchitect/Intent.Modules.NET. Implements Blazor add or create entity dialogs using MudBlazor dialog patterns and valid form submission, preserving existing .razor.cs service behavior while wiring save and cancel correctly. Use when creating or implementing add or create entity dialogs in Blazor, including when an empty or skelet

How to use this skill

Skill file

MANDATORY: Read Samples Before Implementation

STOP — you MUST read ALL of the following before writing ANY code:

Samples (in the SAME folder as this SKILL.md):

  1. add-entity-dialog-sample.razor
  2. add-entity-dialog-sample.razor.cs

Target component and project files:

  1. The target .razor and .razor.cs
  2. Related project files: models, enums, lookups, services

Design and styling context (search the project — these are NOT in the SKILL.md folder):

  1. design.md — search for this file anywhere in the project; read it in full if found; if absent, note the absence and continue without design context
  2. ux-tokens.css, ux-base.css, ux-components.css — read from the project's wwwroot folder if present; note any that are absent

If any sample file (items 1–2) cannot be accessed: stop immediately, confirm the SKILL.md folder location, retry from that location, and if still inaccessible report which file is missing. Do not proceed with partial implementation or approximation.

If items 5–6 are not found: note the absence and continue — they are reference context, not blocking.


Preserve Existing Implementation

Use for: Add or create entity dialogs in Blazor with MudBlazor

Do NOT use for: Full pages, search pages, edit dialogs, or non-Blazor projects

Source of truth: Existing .razor.cs file defines service calls, dialog behavior, and model structure

This is a dialog: close or cancel through MudBlazor dialog APIs rather than navigation

You MUST NOT:


Assess The .razor.cs Before Writing

Read the existing .razor.cs in full. Determine whether it is a skeleton (constructor, injections, and empty or stub methods only) or implemented (contains real model construction, service calls, or save logic).

If skeleton — scaffold the missing members modelled on the sample .razor.cs:

If implemented — preserve all existing logic exactly:


1. Dialog Structure

This component is a MudBlazor dialog, not a page.

Dialog rules:

If input data is needed, receive it through [Parameter] properties or existing project conventions.


2. Save And Cancel Methods

Implement or use top-level methods for the template:

Save() or SaveAsync():

  1. Validate the form
  2. Call the existing backend method without modifying it
  3. On success, close the dialog with a success result
  4. On error, keep the dialog open and set existing error state such as serviceErrors.*

Cancel():

Template bindings:


3. Form And Validation In Dialogs

Use valid Blazor form patterns such as EditForm with the component's existing validation conventions.

Required fields must have:

Save button state:


4. Control Mapping

| Property Type | Control |

|---------------|---------|

| String | MudTextField |

| Boolean | MudSwitch or MudCheckBox |

| Enum | MudSelect with verified numeric values |

| Lookup | MudSelect from real option sources only |

| Array | Repeatable MudBlazor blocks |

| Date | MudDatePicker |

Enum rules:

MudBlazor rules:


5. Child Collections


6. Styling

Design and styling context

Apply the design token and CSS utility context from the files you read in the mandatory phase. Use var(--token) for all inline Style= attributes — never hardcode hex values. Verify utility classes (e.g. ux-fade-in-up, ux-gradient-primary) exist before applying. The design context informs styling choices only — it does not override layout structure.


Definition of Done

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.