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.
This commit is contained in:
@@ -384,6 +384,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
|
||||
var workshopSettings = _customizeWorkshopSettingsRepository.GetBy(command.WorkshopId);
|
||||
|
||||
var employeeSettings =
|
||||
_customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(
|
||||
command.WorkshopId, command.EmployeeId)?.WorkshopShiftStatus;
|
||||
|
||||
@@ -8,6 +8,8 @@ public class CreateProjectCommandValidator:AbstractValidator<CreateProjectComman
|
||||
public CreateProjectCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.Name)
|
||||
.MaximumLength(15)
|
||||
.WithMessage("نام نمیتواند بیشتر از 15 کاراکتر باشد")
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.WithMessage("نام نمیتواند خالی باشد");
|
||||
|
||||
@@ -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<SetTimeProjectCommand>
|
||||
public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCommand>
|
||||
{
|
||||
private readonly IProjectRepository _projectRepository;
|
||||
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||
@@ -16,7 +17,7 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private long? _userId;
|
||||
|
||||
|
||||
|
||||
public SetTimeProjectCommandHandler(
|
||||
IProjectRepository projectRepository,
|
||||
@@ -40,11 +41,11 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
return await SetTimeForProjectTask(request, cancellationToken);
|
||||
default:
|
||||
return OperationResult.Failure("سطح پروژه نامعتبر است");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<OperationResult> SetTimeForProject(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||
private async Task<OperationResult> SetTimeForProject(SetTimeProjectCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var project = await _projectRepository.GetWithFullHierarchyAsync(request.Id);
|
||||
if (project == null)
|
||||
@@ -75,7 +76,8 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
return OperationResult.Success();
|
||||
}
|
||||
|
||||
private async Task<OperationResult> SetTimeForProjectPhase(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||
private async Task<OperationResult> SetTimeForProjectPhase(SetTimeProjectCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var phase = await _projectPhaseRepository.GetWithTasksAsync(request.Id);
|
||||
if (phase == null)
|
||||
@@ -103,13 +105,13 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
return OperationResult.Success();
|
||||
}
|
||||
|
||||
private async Task<OperationResult> SetTimeForProjectTask(SetTimeProjectCommand request, CancellationToken cancellationToken)
|
||||
private async Task<OperationResult> SetTimeForProjectTask(SetTimeProjectCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var task = await _projectTaskRepository.GetWithSectionsAsync(request.Id);
|
||||
if (task == null)
|
||||
{
|
||||
return OperationResult.NotFound("تسک یافت نشد");
|
||||
return OperationResult.NotFound("<22>Ә <20><><EFBFBD><EFBFBD> <20><><EFBFBD>");
|
||||
}
|
||||
|
||||
long? addedByUserId = _userId;
|
||||
@@ -127,12 +129,17 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
}
|
||||
|
||||
|
||||
private void SetSectionTime(TaskSection section, SetTimeProjectSectionItem sectionItem, long? addedByUserId)
|
||||
{
|
||||
var initData = sectionItem.InitData;
|
||||
var initialTime = TimeSpan.FromHours(initData.Hours);
|
||||
|
||||
if (initialTime <= TimeSpan.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// تنظیم زمان اولیه
|
||||
section.UpdateInitialEstimatedHours(initialTime, initData.Description);
|
||||
|
||||
@@ -144,7 +151,7 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private void SetSectionTime(ProjectSection section, SetTimeProjectSectionItem sectionItem, long? addedByUserId)
|
||||
// {
|
||||
// var initData = sectionItem.InitData;
|
||||
@@ -161,4 +168,4 @@ public class SetTimeProjectCommandHandler:IBaseCommandHandler<SetTimeProjectComm
|
||||
// section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using System.Runtime.InteropServices;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.AssignProject;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeStatusSection;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||
@@ -8,6 +9,7 @@ using GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimePro
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.TransferSection;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectAssignDetails;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.ProjectBoardDetail;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.ProjectBoardList;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.ProjectSetTimeDetails;
|
||||
using MediatR;
|
||||
@@ -99,4 +101,11 @@ public class ProjectController : ProgramManagerBaseController
|
||||
var res = await _mediator.Send(query);
|
||||
return res;
|
||||
}
|
||||
[HttpGet("board/{id:guid}")]
|
||||
public async Task<ActionResult<OperationResult<ProjectBoardDetailResponse>>> Test(Guid id)
|
||||
{
|
||||
var query = new ProjectBoardDetailQuery(id);
|
||||
var res = await _mediator.Send(query);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user