- Updated status transitions to include PendingForCompletion before Completed - Added API endpoint and command/handler for approving/rejecting section completion - Fixed additional time calculation to include minutes - Refactored project board query logic and improved user ordering - Updated launch settings with new HTTPS endpoint - Documented progress percentage feature for TaskSection
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||
using GozareshgirProgramManager.Application._Common.Models;
|
||
using GozareshgirProgramManager.Domain._Common;
|
||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||
|
||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ApproveTaskSectionCompletion;
|
||
|
||
public record ApproveTaskSectionCompletionCommand(Guid TaskSectionId, bool IsApproved) : IBaseCommand;
|
||
|
||
public class ApproveTaskSectionCompletionCommandHandler : IBaseCommandHandler<ApproveTaskSectionCompletionCommand>
|
||
{
|
||
private readonly ITaskSectionRepository _taskSectionRepository;
|
||
private readonly IUnitOfWork _unitOfWork;
|
||
private readonly IAuthHelper _authHelper;
|
||
|
||
public ApproveTaskSectionCompletionCommandHandler(
|
||
ITaskSectionRepository taskSectionRepository,
|
||
IUnitOfWork unitOfWork,
|
||
IAuthHelper authHelper)
|
||
{
|
||
_taskSectionRepository = taskSectionRepository;
|
||
_unitOfWork = unitOfWork;
|
||
_authHelper = authHelper;
|
||
}
|
||
|
||
public async Task<OperationResult> Handle(ApproveTaskSectionCompletionCommand request, CancellationToken cancellationToken)
|
||
{
|
||
var currentUserId = _authHelper.GetCurrentUserId()
|
||
?? throw new UnAuthorizedException("˜ÇÑÈÑ ÇÍÑÇÒ åæ?Ê äÔÏå ÇÓÊ");
|
||
|
||
var section = await _taskSectionRepository.GetByIdAsync(request.TaskSectionId, cancellationToken);
|
||
if (section == null)
|
||
{
|
||
return OperationResult.NotFound("ÈÎÔ ãæÑÏ äÙÑ ?ÇÝÊ äÔÏ");
|
||
}
|
||
|
||
if (section.Status != TaskSectionStatus.PendingForCompletion)
|
||
{
|
||
return OperationResult.Failure("ÝÞØ ÈÎÔ<C38E>åÇ?? ˜å ÏÑ ÇäÊÙÇÑ Ê˜ã?á åÓÊäÏ ÞÇÈá ÊÇ??Ï ?Ç ÑÏ åÓÊäÏ");
|
||
}
|
||
|
||
if (request.IsApproved)
|
||
{
|
||
section.UpdateStatus(TaskSectionStatus.Completed);
|
||
}
|
||
else
|
||
{
|
||
section.UpdateStatus(TaskSectionStatus.Incomplete);
|
||
}
|
||
|
||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||
|
||
return OperationResult.Success();
|
||
}
|
||
}
|