Files
Tasker/Tasker/Tasker.Web/Tasking/Endpoints/CreateTask.cs
Jonathan Bourdon 5c93d81ad5 feat(tasking): add projects feature and restructure backend
- Restructure backend code into Tasking module with organized endpoints
  - Add Project and Sprint entities with database migrations
  - Implement CRUD endpoints for projects (create, get, rename, delete)
  - Refactor task endpoints into Tasking namespace
  - Add integration test suite with Testcontainers and Respawn
  - Refactor frontend to use Pinia stores with dedicated API clients
  - Add DueDatePicker and DueTimePicker components for task scheduling
  - Add environment configuration for API base URL
  - Add infrastructure setup scripts for Docker/Postgres
2025-12-16 15:33:35 -05:00

49 lines
1.2 KiB
C#

using Tasker.Web.Tasking.Data;
using Task = System.Threading.Tasks.Task;
namespace Tasker.Web.Tasking.Endpoints;
[PublicAPI]
public record CreateTaskRequest(
Guid Id,
string Name,
string? Description,
DateTimeOffset? DueDate);
[PublicAPI]
public class CreateTaskEndpoint(
ProjectDbContext dbContext)
: Endpoint<CreateTaskRequest>
{
public override void Configure()
{
Post("/tasks");
Options(o => o.WithTags("Tasks"));
AllowAnonymous();
}
public override async Task HandleAsync(
CreateTaskRequest req,
CancellationToken ct)
{
var task = await dbContext
.Tasks
.AddAsync(
new Data.Task
{
Id = req.Id,
CreatedOn = DateTimeOffset.UtcNow,
Name = req.Name,
Description = req.Description,
DueDate = req.DueDate?.ToUniversalTime()
},
cancellationToken: ct);
await dbContext.SaveChangesAsync(ct);
await SendCreatedAtAsync<GetTaskEndpoint>(
task.Entity.Id,
task.Entity,
cancellation: ct);
}
}