.agents/skills/aspnet-mvc-controller/SKILL.md
Sử dụng kỹ năng này khi cần xử lý logic backend, tạo hoặc chỉnh sửa Controllers trong ASP.NET MVC. Kỹ năng này bao gồm xử lý các luồng HTTP GET/POST, mapping dữ liệu từ Model sang ViewModel, kiểm tra ModelState (Validation), và truyền dữ liệu an toàn ra Razor View.
npx skillsauth add Namhahaha1110/WebTrangSuc aspnet-mvc-controllerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Khi bạn được yêu cầu tạo hoặc chỉnh sửa Controller, hãy tuân thủ nghiêm ngặt các quy tắc sau:
ApplicationDbContext trong Controller. Tất cả các thao tác đọc/ghi cơ sở dữ liệu hoặc tính toán phải được gọi thông qua Interface của Service Layer (được inject qua Constructor).[HttpGet], [HttpPost], [HttpPut], [HttpDelete] cho các action.[Route("api/[controller]")] và trả về IActionResult với các hàm như Ok(), BadRequest(), NotFound().[ValidateAntiForgeryToken] cho TẤT CẢ các HttpPost action nhận dữ liệu từ Form để chống tấn công CSRF.if (!ModelState.IsValid) ở đầu mỗi HttpPost action. Nếu dữ liệu không hợp lệ, trả lại chính View đó kèm theo model để hiển thị lỗi.using Microsoft.AspNetCore.Mvc;
public class ProductAdminController : Controller
{
private readonly IProductService _productService;
// Dependency Injection
public ProductAdminController(IProductService productService)
{
_productService = productService;
}
[HttpGet]
public async Task<IActionResult> Index(int page = 1)
{
var products = await _productService.GetPagedProductsAsync(page, 10);
return View(products);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(ProductCreateViewModel model)
{
if (!ModelState.IsValid)
{
return View(model); // Trả lại form kèm thông báo lỗi
}
try
{
await _productService.CreateProductAsync(model);
TempData["SuccessMessage"] = "Thêm sản phẩm thành công!";
return RedirectToAction(nameof(Index));
}
catch (Exception ex)
{
ModelState.AddModelError("", "Đã xảy ra lỗi: " + ex.Message);
return View(model);
}
}
}
development
Optimize website and web application performance including loading speed, Core Web Vitals, bundle size, caching strategies, and runtime performance
tools
UI/UX design intelligence for web and mobile. Includes 50+ styles, 161 color palettes, 57 font pairings, 161 product types, 99 UX guidelines, and 25 chart types across 10 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, and HTML/CSS). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, and check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, and mobile app. Elements: button, modal, navbar, sidebar, card, table, form, and chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, and flat design. Topics: color systems, accessibility, animation, layout, typography, font pairing, spacing, interaction states, shadow, and gradient. Integrations: shadcn/ui MCP for component search and examples.
development
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
development
Sử dụng kỹ năng này khi có yêu cầu liên quan đến Cơ sở dữ liệu (Database), thiết kế Entity Models, hoặc viết các câu truy vấn LINQ bằng Entity Framework Core. Kỹ năng này đảm bảo việc thực thi các tác vụ CRUD được tối ưu hiệu suất, tránh lỗi N+1 query, và xử lý quan hệ dữ liệu chuẩn xác.