feat: refactor task priority handling to use ProjectTaskPriority across commands, DTOs, and repositories
This commit is contained in:
@@ -10,7 +10,7 @@ public record AddTaskToPhaseCommand(
|
||||
Guid PhaseId,
|
||||
string Name,
|
||||
string? Description = null,
|
||||
TaskPriority Priority = TaskPriority.Medium,
|
||||
ProjectTaskPriority Priority = ProjectTaskPriority.Medium,
|
||||
int OrderIndex = 0,
|
||||
DateTime? DueDate = null
|
||||
) : IBaseCommand;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.Change
|
||||
public record ChangeTaskPriorityCommand(
|
||||
Guid Id,
|
||||
ProjectHierarchyLevel Level,
|
||||
TaskPriority Priority
|
||||
ProjectTaskPriority Priority
|
||||
) : IBaseCommand;
|
||||
|
||||
public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPriorityCommand>
|
||||
@@ -47,7 +47,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
||||
}
|
||||
|
||||
// Task-level priority update
|
||||
private async Task<OperationResult> HandleTaskLevelAsync(Guid taskId, TaskPriority priority, CancellationToken ct)
|
||||
private async Task<OperationResult> HandleTaskLevelAsync(Guid taskId, ProjectTaskPriority priority, CancellationToken ct)
|
||||
{
|
||||
var task = await _taskRepository.GetByIdAsync(taskId, ct);
|
||||
if (task is null)
|
||||
@@ -63,7 +63,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
||||
}
|
||||
|
||||
// Phase-level bulk priority update
|
||||
private async Task<OperationResult> HandlePhaseLevelAsync(Guid phaseId, TaskPriority priority, CancellationToken ct)
|
||||
private async Task<OperationResult> HandlePhaseLevelAsync(Guid phaseId, ProjectTaskPriority priority, CancellationToken ct)
|
||||
{
|
||||
var phase = await _phaseRepository.GetWithTasksAsync(phaseId);
|
||||
if (phase is null)
|
||||
@@ -83,7 +83,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
||||
}
|
||||
|
||||
// Project-level bulk priority update across all phases
|
||||
private async Task<OperationResult> HandleProjectLevelAsync(Guid projectId, TaskPriority priority, CancellationToken ct)
|
||||
private async Task<OperationResult> HandleProjectLevelAsync(Guid projectId, ProjectTaskPriority priority, CancellationToken ct)
|
||||
{
|
||||
var project = await _projectRepository.GetWithFullHierarchyAsync(projectId);
|
||||
if (project is null)
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GetTaskDto
|
||||
// Task-specific fields
|
||||
public TimeSpan SpentTime { get; init; }
|
||||
public TimeSpan RemainingTime { get; init; }
|
||||
public TaskPriority Priority { get; set; }
|
||||
public ProjectTaskPriority Priority { get; set; }
|
||||
public List<GetTaskSectionDto> Sections { get; init; }
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
||||
ProjectName = x.Task.Phase.Project.Name,
|
||||
TaskName = x.Task.Name,
|
||||
SectionStatus = x.Status,
|
||||
TaskPriority = x.Task.Priority,
|
||||
Progress = new ProjectProgressDto()
|
||||
{
|
||||
CompleteSecond = x.FinalEstimatedHours.TotalSeconds,
|
||||
|
||||
@@ -13,6 +13,7 @@ public class ProjectBoardListResponse
|
||||
public string? AssignedUser { get; set; }
|
||||
public string OriginalUser { get; set; }
|
||||
public string SkillName { get; set; }
|
||||
public ProjectTaskPriority TaskPriority { get; set; }
|
||||
|
||||
}
|
||||
public class ProjectProgressDto
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
{
|
||||
PhaseId = phaseId;
|
||||
_sections = new List<TaskSection>();
|
||||
Priority = TaskPriority.Medium;
|
||||
Priority = ProjectTaskPriority.Medium;
|
||||
AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
|
||||
// Task-specific properties
|
||||
public Enums.TaskStatus Status { get; private set; } = Enums.TaskStatus.NotStarted;
|
||||
public TaskPriority Priority { get; private set; }
|
||||
public ProjectTaskPriority Priority { get; private set; }
|
||||
public DateTime? StartDate { get; private set; }
|
||||
public DateTime? EndDate { get; private set; }
|
||||
public DateTime? DueDate { get; private set; }
|
||||
@@ -119,7 +119,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
AddDomainEvent(new TaskStatusUpdatedEvent(Id, status));
|
||||
}
|
||||
|
||||
public void SetPriority(TaskPriority priority)
|
||||
public void SetPriority(ProjectTaskPriority priority)
|
||||
{
|
||||
Priority = priority;
|
||||
AddDomainEvent(new TaskPriorityUpdatedEvent(Id, priority));
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
/// <summary>
|
||||
/// اولویت تسک
|
||||
/// </summary>
|
||||
public enum TaskPriority
|
||||
public enum ProjectTaskPriority
|
||||
{
|
||||
/// <summary>
|
||||
/// پایین
|
||||
@@ -78,7 +78,7 @@ public record TaskStatusUpdatedEvent(Guid TaskId, TaskStatus Status) : IDomainEv
|
||||
public DateTime OccurredOn { get; init; } = DateTime.Now;
|
||||
}
|
||||
|
||||
public record TaskPriorityUpdatedEvent(Guid TaskId, TaskPriority Priority) : IDomainEvent
|
||||
public record TaskPriorityUpdatedEvent(Guid TaskId, ProjectTaskPriority Priority) : IDomainEvent
|
||||
{
|
||||
public DateTime OccurredOn { get; init; } = DateTime.Now;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface IProjectTaskRepository : IRepository<Guid, ProjectTask>
|
||||
/// <summary>
|
||||
/// Get tasks by priority
|
||||
/// </summary>
|
||||
Task<List<ProjectTask>> GetByPriorityAsync(ProjectAgg.Enums.TaskPriority priority);
|
||||
Task<List<ProjectTask>> GetByPriorityAsync(ProjectAgg.Enums.ProjectTaskPriority priority);
|
||||
|
||||
/// <summary>
|
||||
/// Get tasks assigned to user
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ProjectTaskRepository : RepositoryBase<Guid, ProjectTask>, IProject
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public Task<List<ProjectTask>> GetByPriorityAsync(TaskPriority priority)
|
||||
public Task<List<ProjectTask>> GetByPriorityAsync(ProjectTaskPriority priority)
|
||||
{
|
||||
return _context.ProjectTasks
|
||||
.Where(t => t.Priority == priority)
|
||||
|
||||
Reference in New Issue
Block a user