115 lines
4.4 KiB
C#
115 lines
4.4 KiB
C#
using System.Runtime.InteropServices;
|
|
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.ChangeStatusSection;
|
|
using GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
|
using GozareshgirProgramManager.Application.Modules.Projects.Commands.DeleteProject;
|
|
using GozareshgirProgramManager.Application.Modules.Projects.Commands.EditProject;
|
|
using GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
|
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;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using ServiceHost.BaseControllers;
|
|
|
|
namespace ServiceHost.Areas.Admin.Controllers.ProgramManager;
|
|
|
|
public class ProjectController : ProgramManagerBaseController
|
|
{
|
|
private readonly IMediator _mediator;
|
|
|
|
public ProjectController(IMediator mediator)
|
|
{
|
|
_mediator = mediator;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult<OperationResult<GetProjectsListResponse>>> Get([FromQuery]GetProjectsListQuery query)
|
|
{
|
|
var res=await _mediator.Send(query);
|
|
return res;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult<OperationResult>> Create([FromBody] CreateProjectCommand command)
|
|
{
|
|
var res=await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
|
|
[HttpPut]
|
|
public async Task<ActionResult<OperationResult>> Edit([FromBody] EditProjectCommand command)
|
|
{
|
|
var res=await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
|
|
[HttpDelete]
|
|
public async Task<ActionResult<OperationResult>> Delete([FromQuery] DeleteProjectCommand command)
|
|
{
|
|
var res=await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
|
|
[HttpGet("assign")]
|
|
public async Task<ActionResult<OperationResult<GetProjectAssignDetailsResponse>>> GetAssignableProjects(GetProjectAssignDetailsQuery query)
|
|
{
|
|
var res=await _mediator.Send(query);
|
|
return res;
|
|
}
|
|
|
|
[HttpPost("assign")]
|
|
public async Task<ActionResult<OperationResult>> Assign(AssignProjectCommand command)
|
|
{
|
|
var res=await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
[HttpGet("set-time")]
|
|
public async Task<ActionResult<OperationResult<ProjectSetTimeResponse>>> GetSetTimeProjectDetails(ProjectSetTimeDetailsQuery query)
|
|
{
|
|
var res=await _mediator.Send(query);
|
|
return res;
|
|
}
|
|
[HttpPost("set-time")]
|
|
public async Task<ActionResult<OperationResult>> SetTimeProject(SetTimeProjectCommand command)
|
|
{
|
|
var res=await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
|
|
[HttpPost("change-status")]
|
|
public async Task<ActionResult<OperationResult>> ChangeStatus(ChangeStatusSectionCommand command)
|
|
{
|
|
var res = await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
|
|
[HttpPost("transfer-section")]
|
|
public async Task<ActionResult<OperationResult>> TransferSection([FromBody] TransferSectionCommand command)
|
|
{
|
|
var res = await _mediator.Send(command);
|
|
return res;
|
|
}
|
|
|
|
[HttpGet("board")]
|
|
public async Task<ActionResult<OperationResult<List<ProjectBoardListResponse>>>> GetProjectBoard([FromQuery] ProjectBoardListQuery query)
|
|
{
|
|
// اجرای Command برای متوقف کردن تسکهای overtime قبل از نمایش
|
|
await _mediator.Send(new AutoStopOverTimeTaskSectionsCommand());
|
|
|
|
var res = await _mediator.Send(query);
|
|
return res;
|
|
}
|
|
[HttpGet("board/details")]
|
|
public async Task<ActionResult<OperationResult<ProjectBoardDetailResponse>>> GetProjectBoardDetails(Guid id)
|
|
{
|
|
var query = new ProjectBoardDetailQuery(id);
|
|
var res = await _mediator.Send(query);
|
|
return res;
|
|
}
|
|
} |