Files
TaskTracker/TaskTracker.Api/Controllers/NotesController.cs
AJ Isaacs e12f78c479 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>
2026-02-26 22:08:45 -05:00

42 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Mvc;
using TaskTracker.Core.DTOs;
using TaskTracker.Core.Entities;
using TaskTracker.Core.Interfaces;
namespace TaskTracker.Api.Controllers;
[ApiController]
[Route("api/tasks/{taskId:int}/notes")]
public class NotesController(ITaskRepository taskRepo) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetNotes(int taskId)
{
var task = await taskRepo.GetByIdAsync(taskId);
if (task is null)
return NotFound(ApiResponse.Fail("Task not found"));
return Ok(ApiResponse<List<TaskNote>>.Ok(task.Notes));
}
[HttpPost]
public async Task<IActionResult> AddNote(int taskId, [FromBody] CreateNoteRequest request)
{
var task = await taskRepo.GetByIdAsync(taskId);
if (task is null)
return NotFound(ApiResponse.Fail("Task not found"));
var note = new TaskNote
{
Content = request.Content,
Type = request.Type,
CreatedAt = DateTime.UtcNow
};
task.Notes.Add(note);
await taskRepo.UpdateAsync(task);
return Ok(ApiResponse<TaskNote>.Ok(note));
}
}