Replace ToNoContent usage on POST commands that create resources with appropriate ToCreated responses, and ensure command handlers return Result<T> with created identifiers where needed. Also verify that duplicate detection returns 409 Conflict and validation errors return 400 Bad Request as expected by the integration test suite.
Important
The proposed changes will modify the public API contract for several endpoints (e.g., AddModule, AddMenu, AddOption, etc.). Ensure this aligns with any external consumers or documentation.
[!QUESTION] Do you prefer the location header for created resources to follow the pattern
/system-suites/{systemSuiteId}/modules/{moduleId}(and similar for menus, options, etc.)?
- [MODIFY]
AddModuleCommandHandler.cs- Change return type to
Result<ModuleId>and return the newly created module identifier.
- Change return type to
- [MODIFY]
AddMenuCommandHandler.cs(similar pattern for menus, submenus, options, app-settings, actions, domain-resources)- Update to return the created entity identifier.
- [MODIFY]
AddModuleendpoint- Replace
result.ToNoContent(context)withresult.ToCreated(r => $"/system-suites/{systemSuiteId}/modules/{r.Value.GetId().GetValue()}", context).
- Replace
- Apply analogous changes to other POST endpoints that create resources (menus, submenus, options, app-settings, actions, domain-resources).
- Ensure GET, PUT, DELETE endpoints continue to use
ToNoContentor appropriate status mappings.
- No changes needed;
ToCreatedalready maps success to201 Created.
- Run
dotnet testafter changes to ensure integration test failures drop from 21 to 0. - Manually inspect a few endpoint responses using curl or a browser to verify
Locationheader and status codes.
- No new tests required; existing integration tests will validate behavior.
- Update API docs (if any) to reflect new response contracts.
- Modify handlers and endpoints (estimated 30 min).
- Run tests and address any failures (estimated 15 min).
- Verify and commit (estimated 10 min).
- Execute
dotnet testin the solution root.
- Use
curl -i -X POST /system-suites/{id}/moduleswith duplicate code to confirm409 Conflict. - Use
curl -i -X POST /system-suites/{id}/moduleswith valid data to confirm201 CreatedandLocationheader.