From a11e54c333a439eadc93e31da939ad0c91d75678 Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 16 Dec 2025 17:09:28 +0330 Subject: [PATCH] Add project board detail endpoint & validation improvements - Added GET /board/{id:guid} endpoint to ProjectController for detailed project board info. - Enforced max length of 15 characters for project names in CreateProjectCommandValidator. - Improved SetTimeProjectCommandHandler: skip zero/negative initial times, removed duplicate error message, and cleaned up formatting. - Enhanced RollCallApplication to use employee-specific workshop shift settings when available. --- .../RollCallApplication.cs | 1 + .../CreateProjectCommandValidator.cs | 2 ++ .../SetTimeProjectCommandHandler.cs | 27 ++++++++++++------- .../ProgramManager/ProjectController.cs | 11 +++++++- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CompanyManagment.Application/RollCallApplication.cs b/CompanyManagment.Application/RollCallApplication.cs index b5b6a873..1730c70d 100644 --- a/CompanyManagment.Application/RollCallApplication.cs +++ b/CompanyManagment.Application/RollCallApplication.cs @@ -384,6 +384,7 @@ public class RollCallApplication : IRollCallApplication var workshopSettings = _customizeWorkshopSettingsRepository.GetBy(command.WorkshopId); + var employeeSettings = _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings( command.WorkshopId, command.EmployeeId)?.WorkshopShiftStatus; diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandValidator.cs index 790e1f79..e112b7f6 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandValidator.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandValidator.cs @@ -8,6 +8,8 @@ public class CreateProjectCommandValidator:AbstractValidator x.Name) + .MaximumLength(15) + .WithMessage("نام نمیتواند بیشتر از 15 کاراکتر باشد") .NotEmpty() .NotNull() .WithMessage("نام نمیتواند خالی باشد"); diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs index 3b1a7b1f..f6e9bafa 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs @@ -2,13 +2,14 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Application.Modules.Projects.DTOs; using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain._Common.Exceptions; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject; -public class SetTimeProjectCommandHandler:IBaseCommandHandler +public class SetTimeProjectCommandHandler : IBaseCommandHandler { private readonly IProjectRepository _projectRepository; private readonly IProjectPhaseRepository _projectPhaseRepository; @@ -16,7 +17,7 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler SetTimeForProject(SetTimeProjectCommand request, CancellationToken cancellationToken) + private async Task SetTimeForProject(SetTimeProjectCommand request, + CancellationToken cancellationToken) { var project = await _projectRepository.GetWithFullHierarchyAsync(request.Id); if (project == null) @@ -75,7 +76,8 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler SetTimeForProjectPhase(SetTimeProjectCommand request, CancellationToken cancellationToken) + private async Task SetTimeForProjectPhase(SetTimeProjectCommand request, + CancellationToken cancellationToken) { var phase = await _projectPhaseRepository.GetWithTasksAsync(request.Id); if (phase == null) @@ -103,13 +105,13 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler SetTimeForProjectTask(SetTimeProjectCommand request, CancellationToken cancellationToken) + private async Task SetTimeForProjectTask(SetTimeProjectCommand request, + CancellationToken cancellationToken) { var task = await _projectTaskRepository.GetWithSectionsAsync(request.Id); if (task == null) { return OperationResult.NotFound("تسک یافت نشد"); - return OperationResult.NotFound("�Ә ���� ���"); } long? addedByUserId = _userId; @@ -127,12 +129,17 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler>> Test(Guid id) + { + var query = new ProjectBoardDetailQuery(id); + var res = await _mediator.Send(query); + return res; + } } \ No newline at end of file