48 lines
1.6 KiB
Markdown
48 lines
1.6 KiB
Markdown
# AI_TASKS.md
|
|
|
|
Quick task cookbook for common changes in this repo.
|
|
|
|
## Add a new API endpoint group
|
|
|
|
1) Create `Freman.Sample.Web/Endpoints/<Feature>Endpoints.cs`
|
|
2) Add an extension method:
|
|
- `public static IEndpointRouteBuilder Map<Feature>Endpoints(this IEndpointRouteBuilder app)`
|
|
3) Call it from `Freman.Sample.Web/Program.cs`:
|
|
- `app.Map<Feature>Endpoints();`
|
|
|
|
## Add a new Client page that calls the API
|
|
|
|
1) Create page in `Freman.Sample.Web.Client/Pages/<Page>.razor`
|
|
2) Ensure it runs as WASM and avoids server prerender DI issues:
|
|
- `@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))`
|
|
3) Inject `HttpClient`:
|
|
- `@inject HttpClient Http`
|
|
4) Call server endpoints under `/api/*`
|
|
|
|
## Add shared request/response models
|
|
|
|
1) Add to `Freman.Sample.Web.Contracts`
|
|
2) Reference contracts project from Server + Client
|
|
3) Use contracts types in endpoints + client code (avoid duplicates)
|
|
|
|
## Add an EF Core migration
|
|
|
|
From solution root:
|
|
|
|
```
|
|
powershell dotnet tool restore
|
|
dotnet tool run dotnet-ef -- migrations add --project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj --startup-project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj ` --output-dir Data\Migrations
|
|
```
|
|
|
|
## Apply migrations manually (optional)
|
|
|
|
```
|
|
powershell dotnet tool run dotnet-ef -- database update --project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj --startup-project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj
|
|
```
|
|
|
|
## Add a confirmation step in the client
|
|
|
|
Use `Freman.Sample.Web.Client/Components/ConfirmModal.razor` and call:
|
|
|
|
- `await _confirmModal.ShowAsync("Title", "Message")`
|