AutoSkill 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.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8/generate_async_enrollment_mvc_architecture" ~/.claude/skills/ecnu-icalk-autoskill-generate-async-enrollment-mvc-architecture && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/generate_async_enrollment_mvc_architecture/SKILL.mdsource content
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
- Framework & Base Class: The project is ASP.NET Core MVC (not Web API). The
must inherit fromEnrollmentsController
, NOTController
.ControllerBase - Async Pattern: All controller actions performing I/O operations (e.g., database access) MUST use the
keyword and returnasync
. UseTask<IActionResult>
when calling service methods.await - Service Architecture: Create the service as two separate files:
(interface) andIEnrollmentService.cs
(implementation). Ensure service method names reflect the asynchronous nature (e.g.,EnrollmentService.cs
).CreateEnrollmentAsync - Data Access: The
should use aEnrollmentService
(DbContext) injected via the constructor to perform database operations.DataContext - Dependency Injection: Provide the C# code to register
andIEnrollmentService
in theDataContext
file'sStartup.cs
method usingConfigureServices
andservices.AddScoped
.services.AddDbContext - User Context: Retrieve the current user's ID directly from the
usingClaimsPrincipal
. Assign this ID string to the entity'sUser.FindFirstValue(ClaimTypes.NameIdentifier)
property before calling the service create/update method. Do NOT useUserId
or email lookups to find the ID.UserManager
Anti-Patterns
- Do not use
,[ApiController]
, or[Route("api...")]
.ControllerBase - Do not return JSON results like
orOk()
; use Views or Redirects.NoContent() - Do not use synchronous methods (
orvoid
withoutIActionResult
) for actions involving service calls.Task - Do not use
or similar email-based lookups to get the ID._userManager.GetByMail(User.Identity.Name) - Do not put the interface and class in the same file; keep them separate.
Interaction Workflow
- Analyze the provided
model structure.Enrollment - Generate the
interface with asynchronous method signatures.IEnrollmentService - Generate the
class implementing the interface asynchronously.EnrollmentService - Generate the
inheriting fromEnrollmentsController
, injectingController
.IEnrollmentService - Implement actions (e.g., Create) using
, retrieving the user ID viaasync Task<IActionResult>
.User.FindFirstValue(ClaimTypes.NameIdentifier) - Provide the
configuration snippet.Startup.cs
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