--- task_id: task_3 story_id: story_0 sprint_id: sprint_4 status: not_started type: backend assignee: backend created_date: 2025-11-05 completion_date: null --- # Task 3: Add Order Field to Task Entity ## What to do Add an Order field to the WorkTask entity to support manual task reordering via drag-and-drop in the frontend. ## Files to modify - `colaflow-api/src/Modules/ProjectManagement/ColaFlow.Modules.ProjectManagement.Domain/Aggregates/ProjectAggregate/WorkTask.cs` - `colaflow-api/src/Modules/ProjectManagement/ColaFlow.Modules.ProjectManagement.Infrastructure/Persistence/Configurations/WorkTaskConfiguration.cs` ## Implementation ### WorkTask.cs Changes Add property: ```csharp public int Order { get; private set; } ``` Update Create method to set default Order: ```csharp public static WorkTask Create(TenantId tenantId, string title, string description, StoryId storyId, TaskPriority priority, UserId createdBy) { // Existing validation... return new WorkTask { // Existing fields... Order = 0, // Default order // ... }; } ``` Add method: ```csharp public void UpdateOrder(int newOrder) { if (newOrder < 0) throw new DomainException("Task order cannot be negative"); Order = newOrder; UpdatedAt = DateTime.UtcNow; } ``` ### WorkTaskConfiguration.cs Changes Add column configuration and index: ```csharp builder.Property(t => t.Order) .IsRequired() .HasDefaultValue(0); builder.HasIndex(t => new { t.StoryId, t.Order }) .HasDatabaseName("IX_Tasks_StoryId_Order"); ``` ## Acceptance - [ ] WorkTask entity has Order property (int, default 0) - [ ] Create method sets default Order to 0 - [ ] UpdateOrder method validates non-negative - [ ] EF Core configuration includes Order column - [ ] Composite index created (StoryId, Order) - [ ] Code compiles successfully - [ ] Validation tests written - [ ] Tests passing