From 061058cbeb181f7d5bdc6dbbbe1e6bddebdb6296 Mon Sep 17 00:00:00 2001 From: mahan Date: Wed, 7 Jan 2026 11:21:58 +0330 Subject: [PATCH 1/2] fix change status error --- .../Persistence/Repositories/TaskSectionRepository.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs index 1b29e154..d6d60b69 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs @@ -19,6 +19,7 @@ public class TaskSectionRepository:RepositoryBase,ITaskSection { return await _context.TaskSections .Include(x => x.Activities) + .Include(x=>x.AdditionalTimes) .FirstOrDefaultAsync(x => x.Id == id, cancellationToken); } From 2bea2659895fffce4709202c5b4d686ef1defd73 Mon Sep 17 00:00:00 2001 From: mahan Date: Wed, 7 Jan 2026 12:11:24 +0330 Subject: [PATCH 2/2] feat: implement task priority change command and update project/task DTOs --- .../ChangeTaskPriorityCommand.cs | 41 +++++++++++++++++++ .../GetProjectsListQueryHandler.cs | 1 + .../Queries/GetProjectsList/GetTaskListDto.cs | 1 + .../ProgramManager/ProjectController.cs | 1 + 4 files changed, 44 insertions(+) create mode 100644 ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs new file mode 100644 index 00000000..23d23830 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs @@ -0,0 +1,41 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; + +namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeTaskPriority; + +/// +/// Command to change a task priority. +/// +public record ChangeTaskPriorityCommand(Guid TaskId, TaskPriority Priority) : IBaseCommand; + +public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler +{ + private readonly IProjectTaskRepository _taskRepository; + private readonly IUnitOfWork _unitOfWork; + + public ChangeTaskPriorityCommandHandler(IProjectTaskRepository taskRepository, IUnitOfWork unitOfWork) + { + _taskRepository = taskRepository; + _unitOfWork = unitOfWork; + } + + public async Task Handle(ChangeTaskPriorityCommand request, CancellationToken cancellationToken) + { + var task = await _taskRepository.GetByIdAsync(request.TaskId, cancellationToken); + if (task is null) + return OperationResult.NotFound("تسک یافت نشد"); + + // Idempotent: if already same priority, skip extra work + if (task.Priority != request.Priority) + { + task.SetPriority(request.Priority); + } + + await _unitOfWork.SaveChangesAsync(cancellationToken); + return OperationResult.Success(); + } +} + diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectsList/GetProjectsListQueryHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectsList/GetProjectsListQueryHandler.cs index d26a06b1..a982caf3 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectsList/GetProjectsListQueryHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectsList/GetProjectsListQueryHandler.cs @@ -189,6 +189,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler Sections { get; init; } } diff --git a/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs b/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs index 290c5cab..fe3dbb6f 100644 --- a/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs +++ b/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs @@ -22,6 +22,7 @@ using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectH using MediatR; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; +using GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeTaskPriority; namespace ServiceHost.Areas.Admin.Controllers.ProgramManager;