Merge branch 'Main' of https://github.com/samsyntax24/OriginalGozareshgir into Main
This commit is contained in:
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Command to change a task priority.
|
||||
/// </summary>
|
||||
public record ChangeTaskPriorityCommand(Guid TaskId, TaskPriority Priority) : IBaseCommand;
|
||||
|
||||
public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPriorityCommand>
|
||||
{
|
||||
private readonly IProjectTaskRepository _taskRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public ChangeTaskPriorityCommandHandler(IProjectTaskRepository taskRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_taskRepository = taskRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
SpentTime = spentTime,
|
||||
RemainingTime = remainingTime,
|
||||
Sections = sectionDtos,
|
||||
Priority = task.Priority
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -15,6 +15,7 @@ public class GetTaskDto
|
||||
// Task-specific fields
|
||||
public TimeSpan SpentTime { get; init; }
|
||||
public TimeSpan RemainingTime { get; init; }
|
||||
public TaskPriority Priority { get; set; }
|
||||
public List<GetTaskSectionDto> Sections { get; init; }
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public class TaskSectionRepository:RepositoryBase<Guid,TaskSection>,ITaskSection
|
||||
{
|
||||
return await _context.TaskSections
|
||||
.Include(x => x.Activities)
|
||||
.Include(x=>x.AdditionalTimes)
|
||||
.FirstOrDefaultAsync(x => x.Id == id, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user