Merge branch 'Feature/program-manager/test-upload' into Main
This commit is contained in:
@@ -25,7 +25,7 @@ public class AutoUpdateDeployStatusCommandHandler : IBaseCommandHandler<AutoUpda
|
||||
var sections = await _dbContext.TaskSections
|
||||
.Include(ts => ts.Task)
|
||||
.ThenInclude(t => t.Phase)
|
||||
.Where(ts => ts.Task.Phase.DeployStatus == ProjectDeployStatus.NoTCompleted)
|
||||
.Where(ts => ts.Task.Phase.DeployStatus == ProjectDeployStatus.NotCompleted)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
if (sections.Count == 0)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeDeployStatusProject;
|
||||
|
||||
public record ChangeDeployStatusProjectCommand(Guid PhaseId, ProjectDeployStatus Status):IBaseCommand;
|
||||
|
||||
public class ChangeDeployStatusProjectCommandHandler : IBaseCommandHandler<ChangeDeployStatusProjectCommand>
|
||||
{
|
||||
private readonly IProjectRepository _projectRepository;
|
||||
private readonly IProjectPhaseRepository _projectPhaseRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public ChangeDeployStatusProjectCommandHandler(IProjectRepository projectRepository, IUnitOfWork unitOfWork, IProjectPhaseRepository projectPhaseRepository)
|
||||
{
|
||||
_projectRepository = projectRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
_projectPhaseRepository = projectPhaseRepository;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(ChangeDeployStatusProjectCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var project = await _projectPhaseRepository.GetByIdAsync(request.PhaseId, cancellationToken);
|
||||
if (project == null)
|
||||
return OperationResult.NotFound("بخش مورد نظر یافت نشد");
|
||||
|
||||
if (project.DeployStatus == ProjectDeployStatus.NotCompleted)
|
||||
{
|
||||
return OperationResult.Failure("وضعیت استقرار نمیتواند از حالت 'تایید نشده' تغییر کند.");
|
||||
}
|
||||
project.UpdateDeployStatus(request.Status);
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return OperationResult.Success();
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class ProjectDeployBoardListQueryHandler:IBaseQueryHandler<GetProjectDepl
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Status == TaskSectionStatus.Completed
|
||||
|| x.Status == TaskSectionStatus.PendingForCompletion
|
||||
|| x.Task.Phase.DeployStatus != ProjectDeployStatus.NoTCompleted)
|
||||
|| x.Task.Phase.DeployStatus != ProjectDeployStatus.NotCompleted)
|
||||
.GroupBy(x=>x.Task.PhaseId).ToListAsync(cancellationToken: cancellationToken);
|
||||
|
||||
var list = query.Select(g => new ProjectDeployBoardListItem
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ProjectPhase : ProjectHierarchyNode
|
||||
ProjectId = projectId;
|
||||
_tasks = new List<ProjectTask>();
|
||||
_phaseSections = new List<PhaseSection>();
|
||||
DeployStatus = ProjectDeployStatus.NoTCompleted;
|
||||
DeployStatus = ProjectDeployStatus.NotCompleted;
|
||||
AddDomainEvent(new PhaseCreatedEvent(Id, projectId, name));
|
||||
}
|
||||
|
||||
@@ -211,12 +211,16 @@ public class ProjectPhase : ProjectHierarchyNode
|
||||
public void UpdateDeployStatus(ProjectDeployStatus status)
|
||||
{
|
||||
DeployStatus = status;
|
||||
if (status == ProjectDeployStatus.Deployed)
|
||||
{
|
||||
IsArchived = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ProjectDeployStatus
|
||||
{
|
||||
NoTCompleted,
|
||||
NotCompleted,
|
||||
PendingDevDeploy,
|
||||
DevDeployed,
|
||||
PendingDeploy,
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace GozareshgirProgramManager.Domain._Common;
|
||||
public interface IRepository<TKey, T> where T:class
|
||||
{
|
||||
T Get(TKey id);
|
||||
Task<T?> GetByIdAsync(TKey id);
|
||||
Task<T?> GetByIdAsync(TKey id, CancellationToken cancellationToken = default);
|
||||
List<T> Get();
|
||||
IQueryable<T> GetQueryable();
|
||||
void Create(T entity);
|
||||
|
||||
@@ -43,9 +43,9 @@ public class RepositoryBase<TKey, T> : IRepository<TKey, T> where T : class
|
||||
return _context.Find<T>(id);
|
||||
}
|
||||
|
||||
public async Task<T?> GetByIdAsync(TKey id)
|
||||
public async Task<T?> GetByIdAsync(TKey id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _context.Set<T>().FindAsync(id);
|
||||
return await _context.Set<T>().FindAsync([id], cancellationToken);
|
||||
}
|
||||
|
||||
public List<T> Get()
|
||||
|
||||
@@ -3,6 +3,7 @@ using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.AssignProject;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.AutoStopOverTimeTaskSections;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.AutoUpdateDeployStatus;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeDeployStatusProject;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeStatusSection;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||
using GozareshgirProgramManager.Application.Modules.Projects.Commands.DeleteProject;
|
||||
@@ -138,4 +139,11 @@ public class ProjectController : ProgramManagerBaseController
|
||||
var res = await _mediator.Send(query);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("deploy-board/change-status")]
|
||||
public async Task<ActionResult<OperationResult>> ChangeDeployStatus(ChangeDeployStatusProjectCommand command)
|
||||
{
|
||||
var res = await _mediator.Send(command);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user