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.ProjectDeployBoardList; 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>> Get([FromQuery]GetProjectsListQuery query) { var res=await _mediator.Send(query); return res; } [HttpPost] public async Task> Create([FromBody] CreateProjectCommand command) { var res=await _mediator.Send(command); return res; } [HttpPut] public async Task> Edit([FromBody] EditProjectCommand command) { var res=await _mediator.Send(command); return res; } [HttpDelete] public async Task> Delete([FromQuery] DeleteProjectCommand command) { var res=await _mediator.Send(command); return res; } [HttpGet("assign")] public async Task>> GetAssignableProjects(GetProjectAssignDetailsQuery query) { var res=await _mediator.Send(query); return res; } [HttpPost("assign")] public async Task> Assign(AssignProjectCommand command) { var res=await _mediator.Send(command); return res; } [HttpGet("set-time")] public async Task>> GetSetTimeProjectDetails(ProjectSetTimeDetailsQuery query) { var res=await _mediator.Send(query); return res; } [HttpPost("set-time")] public async Task> SetTimeProject(SetTimeProjectCommand command) { var res=await _mediator.Send(command); return res; } [HttpPost("change-status")] public async Task> ChangeStatus(ChangeStatusSectionCommand command) { var res = await _mediator.Send(command); return res; } [HttpPost("transfer-section")] public async Task> TransferSection([FromBody] TransferSectionCommand command) { var res = await _mediator.Send(command); return res; } [HttpGet("board")] public async Task>>> 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>> GetProjectBoardDetails(Guid id) { var query = new ProjectBoardDetailQuery(id); var res = await _mediator.Send(query); return res; } [HttpGet("deploy-board")] public async Task>> GetProjectDeployBoard() { var request = new GetProjectDeployBoardListQuery(); return await _mediator.Send(request); } }