- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
Create CRUD endpoints for OpenAiPrompt entity in Admin section #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com>
Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com>
| 
          
 Important Review skippedBot user detected. To trigger a single review, invoke the  You can disable this status message by setting the  🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 CodeRabbit Configuration File (
 | 
    
This PR implements CRUD endpoints for the OpenAiPrompt entity within the Admin section as requested in the issue.
Changes Made
1. Created DTO and Request Models
2. Implemented AiPromptController
/api/admin/ai-prompts[HasAnyRole(Role.Admin)]GET /api/admin/ai-prompts- Returns non-paginated list of all OpenAI promptsPOST /api/admin/ai-prompts- Creates new OpenAI promptPUT /api/admin/ai-prompts- Updates existing OpenAI promptDELETE /api/admin/ai-prompts/{id}- Deletes OpenAI prompt by ID3. Enhanced OpenAiPrompt Entity
IHasIdBase<OpenAiPromptType>interface to support enum-based ID operationsUpdatePrompt(),UpdateModel(),UpdateEngine()4. Extended Database Context Utilities
ByIdOrFailAsync<T, TKey>andByIdOrNullAsync<T, TKey>to handle enum-based ID lookupsAPI Usage Examples
Technical Notes
The OpenAiPrompt entity uses
OpenAiPromptTypeenum as the primary key instead of the typicallongID, which required special handling in the extension methods and CRUD operations. All endpoints follow existing patterns for authorization, validation, and error handling.Fixes #138.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.