From 20ece4886cf589a0b2bd1523ec87e4427b2af750 Mon Sep 17 00:00:00 2001 From: mahan Date: Mon, 12 Jan 2026 12:20:08 +0330 Subject: [PATCH] add task priority to CreateProjectCommand --- .../CreateProject/CreateProjectCommand.cs | 1 + .../CreateProjectCommandHandler.cs | 18 ++++++++++-------- .../ProjectAgg/Entities/ProjectTask.cs | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommand.cs index 475e7aab..547f09bb 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommand.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommand.cs @@ -4,4 +4,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Enums; namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject; public record CreateProjectCommand(string Name,ProjectHierarchyLevel Level, + ProjectTaskPriority? Priority, Guid? ParentId):IBaseCommand; \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs index 1ba61509..ef4a4292 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs @@ -16,7 +16,8 @@ public class CreateProjectCommandHandler : IBaseCommandHandlerx.Id == request.ParentId.Value)) + + if (!_projectRepository.Exists(x => x.Id == request.ParentId.Value)) { throw new BadRequestException("والد پروژه یافت نشد"); } @@ -69,14 +70,15 @@ public class CreateProjectCommandHandler : IBaseCommandHandlerx.Id == request.ParentId.Value)) + + if (!_projectPhaseRepository.Exists(x => x.Id == request.ParentId.Value)) { throw new BadRequestException("والد پروژه یافت نشد"); } - var projectTask = new ProjectTask(request.Name, request.ParentId.Value); + var priority = request.Priority ?? ProjectTaskPriority.Low; + + var projectTask = new ProjectTask(request.Name, request.ParentId.Value, priority); await _projectTaskRepository.CreateAsync(projectTask); } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs index 8c11e2a0..81d0e861 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs @@ -16,11 +16,11 @@ public class ProjectTask : ProjectHierarchyNode _sections = new List(); } - public ProjectTask(string name, Guid phaseId, string? description = null) : base(name, description) + public ProjectTask(string name, Guid phaseId,ProjectTaskPriority priority, string? description = null) : base(name, description) { PhaseId = phaseId; _sections = new List(); - Priority = ProjectTaskPriority.Low; + Priority = priority; AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name)); }