chore: initial commit of TaskTracker project
Existing ASP.NET API with vanilla JS SPA, WindowWatcher, Chrome extension, and MCP server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
56
TaskTracker.Api/Controllers/MappingsController.cs
Normal file
56
TaskTracker.Api/Controllers/MappingsController.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TaskTracker.Core.DTOs;
|
||||
using TaskTracker.Core.Entities;
|
||||
using TaskTracker.Core.Interfaces;
|
||||
|
||||
namespace TaskTracker.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class MappingsController(IAppMappingRepository mappingRepo) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var mappings = await mappingRepo.GetAllAsync();
|
||||
return Ok(ApiResponse<List<AppMapping>>.Ok(mappings));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] CreateAppMappingRequest request)
|
||||
{
|
||||
var mapping = new AppMapping
|
||||
{
|
||||
Pattern = request.Pattern,
|
||||
MatchType = request.MatchType,
|
||||
Category = request.Category,
|
||||
FriendlyName = request.FriendlyName
|
||||
};
|
||||
|
||||
var created = await mappingRepo.CreateAsync(mapping);
|
||||
return Ok(ApiResponse<AppMapping>.Ok(created));
|
||||
}
|
||||
|
||||
[HttpPut("{id:int}")]
|
||||
public async Task<IActionResult> Update(int id, [FromBody] CreateAppMappingRequest request)
|
||||
{
|
||||
var mapping = await mappingRepo.GetByIdAsync(id);
|
||||
if (mapping is null)
|
||||
return NotFound(ApiResponse.Fail("Mapping not found"));
|
||||
|
||||
mapping.Pattern = request.Pattern;
|
||||
mapping.MatchType = request.MatchType;
|
||||
mapping.Category = request.Category;
|
||||
mapping.FriendlyName = request.FriendlyName;
|
||||
await mappingRepo.UpdateAsync(mapping);
|
||||
|
||||
return Ok(ApiResponse<AppMapping>.Ok(mapping));
|
||||
}
|
||||
|
||||
[HttpDelete("{id:int}")]
|
||||
public async Task<IActionResult> Delete(int id)
|
||||
{
|
||||
await mappingRepo.DeleteAsync(id);
|
||||
return Ok(ApiResponse.Ok());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user