mcpField
D
d1-06-crud-endpoints

d1-06-crud-endpoints

github.com/softinter-chiangraiDevelopment046 installsUpdated 9w ago
Repository

About d1-06-crud-endpoints

A development skill for adding CRUD endpoints to a previously migrated entity, then redeploying the application. It requires confirmation of the entity before proceeding.

Key features

  1. 01Confirm the migrated entity first
  2. 02Add CRUD endpoints in an ASP.NET controller
  3. 03Redeploy after endpoint changes

Use cases

  1. 01Create API endpoints for a confirmed migrated entity
  2. 02Continue a development sequence through redeployment

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/softinter-chiangrai/up-ai-skill-training --skill d1-06-crud-endpoints

After installing, type/d1-06-crud-endpointsin Claude Code to confirm it loaded.

Details

From the project README

Day 1 · Step 6 — CRUD endpoints, then redeploy

Before starting: Ask which entity to create endpoints for (must match one already migrated in D1_05). Do not assume or proceed without confirmation.

up-api/Controllers/<Entity>sController.cs:

[ApiController]
[Route("api/[controller]")]
public class <Entity>sController : ControllerBase
{
    private readonly AppDbContext _db;
    public <Entity>sController(AppDbContext db) => _db = db;

    [HttpGet]
    public async Task<IActionResult> All() => Ok(await _db.<Entity>s.ToListAsync());

    [HttpGet("detail/{id}")]
    public async Task<IActionResult> Detail(int id)
    {
        var item = await _db.<Entity>s.FindAsync(id);
        return item is null ? NotFound() : Ok(item);
    }

    [HttpPost("save")]
    public async Task<IActionResult> Save(<Entity> input)
    {
        _db.<Entity>s.Add(input);
        await _db.SaveChangesAsync();
        return Ok(input);
    }

    [HttpPut("update/{id}")]
    public async Task<IActionResult> Update(int id, <Entity> input)
    {
        var item = await _db.<Entity>s.FindAsync(id);
        if (item is null) return NotFound();
        // copy updated fields from input onto item
        await _db.SaveChangesAsync();
        return Ok(item);
    }

    [HttpDelete("{id}")]
    public async Task<IActionResult> Delete(int id)
    {
        var item = await _db.<Entity>s.FindAsync(id);
        if (item is null) return NotFound();
        _db.<Entity>s.Remove(item);
        await _db.SaveChangesAsync();
        return NoContent();
    }
}

Comments

Markdown supported