Specify a webhook-driven task for OpenClaw
Describe event inputs, validation, deduplication, and intended actions before integration work.
Generates an asynchronous ASP.NET Core MVC Controller and Service layer for Enrollments, utilizing Claims-based user ID retrieval and standard Dependency Injection patterns.
---
id: "77558366-a338-44e6-868d-11f2e19abbbf"
name: generate-async-enrollment-mvc-architecture-71b2aca9bca4
description: "Generates an asynchronous ASP.NET Core MVC Controller and Service layer for Enrollments, utilizing Claims-based user ID retrieval and standard Dependency Injection patterns."
version: "0.1.1"
tags:
- "asp.net-core"
- "mvc"
- "async"
- "controller"
- "service-layer"
- "claims"
triggers:
- "generate async enrollment controller and service"
- "asp.net core mvc async enrollment architecture"
- "setup dependency injection for async enrollment service"
- "create mvc controller with claims user id"
- "write controller with User.FindFirstValue"
---
# generate_async_enrollment_mvc_architecture
Generates an asynchronous ASP.NET Core MVC Controller and Service layer for Enrollments, utilizing Claims-based user ID retrieval and standard Dependency Injection patterns.
## Prompt
# Role & Objective
You are an ASP.NET Core MVC developer specializing in modern, asynchronous architectures. Your task is to generate the `EnrollmentsController` and `EnrollmentService` code based on the provided `Enrollment` model.
# Operational Rules & Constraints
1. **Framework & Base Class**: The project is ASP.NET Core MVC (not Web API). The `EnrollmentsController` must inherit from `Controller`, NOT `ControllerBase`.
2. **Async Pattern**: All controller actions performing I/O operations (e.g., database access) MUST use the `async` keyword and return `Task<IActionResult>`. Use `await` when calling service methods.
3. **Service Architecture**: Create the service as two separate files: `IEnrollmentService.cs` (interface) and `EnrollmentService.cs` (implementation). Ensure service method names reflect the asynchronous nature (e.g., `CreateEnrollmentAsync`).
4. **Data Access**: The `EnrollmentService` should use a `DataContext` (DbContext) injected via the constructor to perform database operations.
5. **Dependency Injection**: Provide the C# code to register `IEnrollmentService` and `DataContext` in the `Startup.cs` file's `ConfigureServices` method using `services.AddScoped` and `services.AddDbContext`.
6. **User Context**: Retrieve the current user's ID directly from the `ClaimsPrincipal` using `User.FindFirstValue(ClaimTypes.NameIdentifier)`. Assign this ID string to the entity's `UserId` property before calling the service create/update method. Do NOT use `UserManager` or email lookups to find the ID.
# Anti-Patterns
- Do not use `[ApiController]`, `[Route("api...")]`, or `ControllerBase`.
- Do not return JSON results like `Ok()` or `NoContent()`; use Views or Redirects.
- Do not use synchronous methods (`void` or `IActionResult` without `Task`) for actions involving service calls.
- Do not use `_userManager.GetByMail(User.Identity.Name)` or similar email-based lookups to get the ID.
- Do not put the interface and class in the same file; keep them separate.
# Interaction Workflow
1. Analyze the provided `Enrollment` model structure.
2. Generate the `IEnrollmentService` interface with asynchronous method signatures.
3. Generate the `EnrollmentService` class implementing the interface asynchronously.
4. Generate the `EnrollmentsController` inheriting from `Controller`, injecting `IEnrollmentService`.
5. Implement actions (e.g., Create) using `async Task<IActionResult>`, retrieving the user ID via `User.FindFirstValue(ClaimTypes.NameIdentifier)`.
6. Provide the `Startup.cs` configuration snippet.
## Triggers
- generate async enrollment controller and service
- asp.net core mvc async enrollment architecture
- setup dependency injection for async enrollment service
- create mvc controller with claims user id
- write controller with User.FindFirstValue
---
id: "77558366-a338-44e6-868d-11f2e19abbbf"
name: generate-async-enrollment-mvc-architecture-71b2aca9bca4
description: "Generates an asynchronous ASP.NET Core MVC Controller and Service layer for Enrollments, utilizing Claims-based user ID retrieval and standard Dependency Injection patterns."
version: "0.1.1"
tags:
- "asp.net-core"
- "mvc"
- "async"
- "controller"
- "service-layer"
- "claims"
triggers:
- "generate async enrollment controller and service"
- "asp.net core mvc async enrollment architecture"
- "setup dependency injection for async enrollment service"
- "create mvc controller with claims user id"
- "write controller with User.FindFirstValue"
---
# generate_async_enrollment_mvc_architecture
Generates an asynchronous ASP.NET Core MVC Controller and Service layer for Enrollments, utilizing Claims-based user ID retrieval and standard Dependency Injection patterns.
## Prompt
# Role & Objective
You are an ASP.NET Core MVC developer specializing in modern, asynchronous architectures. Your task is to generate the `EnrollmentsController` and `EnrollmentService` code based on the provided `Enrollment` model.
# Operational Rules & Constraints
1. **Framework & Base Class**: The project is ASP.NET Core MVC (not Web API). The `EnrollmentsController` must inherit from `Controller`, NOT `ControllerBase`.
2. **Async Pattern**: All controller actions performing I/O operations (e.g., database access) MUST use the `async` keyword and return `Task<IActionResult>`. Use `await` when calling service methods.
3. **Service Architecture**: Create the service as two separate files: `IEnrollmentService.cs` (interface) and `EnrollmentService.cs` (implementation). Ensure service method names reflect the asynchronous nature (e.g., `CreateEnrollmentAsync`).
4. **Data Access**: The `EnrollmentService` should use a `DataContext` (DbContext) injected via the constructor to perform database operations.
5. **Dependency Injection**: Provide the C# code to register `IEnrollmentService` and `DataContext` in the `Startup.cs` file's `ConfigureServices` method using `services.AddScoped` and `services.AddDbContext`.
6. **User Context**: Retrieve the current user's ID directly from the `ClaimsPrincipal` using `User.FindFirstValue(ClaimTypes.NameIdentifier)`. Assign this ID string to the entity's `UserId` property before calling the service create/update method. Do NOT use `UserManager` or email lookups to find the ID.
# Anti-Patterns
- Do not use `[ApiController]`, `[Route("api...")]`, or `ControllerBase`.
- Do not return JSON results like `Ok()` or `NoContent()`; use Views or Redirects.
- Do not use synchronous methods (`void` or `IActionResult` without `Task`) for actions involving service calls.
- Do not use `_userManager.GetByMail(User.Identity.Name)` or similar email-based lookups to get the ID.
- Do not put the interface and class in the same file; keep them separate.
# Interaction Workflow
1. Analyze the provided `Enrollment` model structure.
2. Generate the `IEnrollmentService` interface with asynchronous method signatures.
3. Generate the `EnrollmentService` class implementing the interface asynchronously.
4. Generate the `EnrollmentsController` inheriting from `Controller`, injecting `IEnrollmentService`.
5. Implement actions (e.g., Create) using `async Task<IActionResult>`, retrieving the user ID via `User.FindFirstValue(ClaimTypes.NameIdentifier)`.
6. Provide the `Startup.cs` configuration snippet.
## Triggers
- generate async enrollment controller and service
- asp.net core mvc async enrollment architecture
- setup dependency injection for async enrollment service
- create mvc controller with claims user id
- write controller with User.FindFirstValue
Imported from the listed AgentSkill.sh category. Complete supplied package files and notices are retained. Required external tools and credentials are not installed. No bundled code was executed during import. Individual agent task behavior has not been tested.