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:
41
TaskTracker.Api/Controllers/NotesController.cs
Normal file
41
TaskTracker.Api/Controllers/NotesController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user