using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Application.Modules.Projects.Commands.ApproveTaskSectionCompletion; using GozareshgirProgramManager.Application.Modules.Projects.Commands.AssignProject; using GozareshgirProgramManager.Application.Modules.Projects.Commands.AutoPendingFullTimeTaskSections; 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.ChangeTaskPriority; using GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateBugSection; 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.GetProjectHierarchySearch; 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.ProjectDeployBoardDetail; using GozareshgirProgramManager.Application.Modules.Projects.Queries.ProjectDeployBoardList; using GozareshgirProgramManager.Application.Modules.Projects.Queries.ProjectSetTimeDetails; using MediatR; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; using System.Runtime.InteropServices; using GozareshgirProgramManager.Application.Modules.Projects.Commands.bugTimeRequestFromUser; using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetBugModalDetails; using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetBugRequestTimeModalDetails; 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; } [HttpGet("search")] public async Task>> Search( [FromQuery] string search) { var searchQuery = new GetProjectSearchQuery(search); var res = await _mediator.Send(searchQuery); 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()); // سپس تسک‌هایی که به 100% زمان تخمینی رسیده‌اند را به حالت PendingForCompletion ببریم await _mediator.Send(new AutoPendingFullTimeTaskSectionsCommand()); 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() { // قبل از دریافت دیتا، وضعیت دیپلوی را بر اساس تکمیل شدن تمام سکشن‌ها به‌روزرسانی می‌کنیم await _mediator.Send(new AutoUpdateDeployStatusCommand()); var request = new GetProjectDeployBoardListQuery(); return await _mediator.Send(request); } [HttpGet("deploy-board/details")] public async Task>> GetProjectDeployBoardDetails(Guid id) { var query = new ProjectDeployBoardDetailsQuery(id); var res = await _mediator.Send(query); return res; } [HttpPost("deploy-board/change-status")] public async Task> ChangeDeployStatus(ChangeDeployStatusProjectCommand command) { var res = await _mediator.Send(command); return res; } [HttpPost("approve-completion")] public async Task> ApproveTaskSectionCompletion([FromBody] ApproveTaskSectionCompletionCommand command) { var res = await _mediator.Send(command); return res; } [HttpPost("change-priority")] public async Task> ChangePriority([FromBody] ChangeTaskPriorityCommand command) { var res = await _mediator.Send(command); return res; } /// /// دریافت اطلاعات مودال ایجاد تسک باگ /// /// /// [HttpGet("GetCreateBugModalDetails")] public async Task>> GetCreateBugModalDetails( [FromQuery] GetBugModalDetailsQuery query) { var res = await _mediator.Send(query); return res; } /// /// ایجاد تسک باگ /// /// /// [HttpPost("CreateBugSection")] public async Task> CreateBugSection([FromBody] CreateBugSectionCommand commnd) { var res = await _mediator.Send(commnd); return res; } /// /// دریافت اطلاعات مودال درخواست زمان برای باگ /// /// /// [HttpGet("GetBugTimeRequestModalDetails")] public async Task>> GetBugTimeRequestModalDetails( [FromQuery] GetBugRequestTimeModalDetailsQuery query) { var res = await _mediator.Send(query); return res; } /// /// ارسال درخواست زمان برای باگ /// /// /// [HttpPost("BugTimeRequestFromUser")] public async Task> BugTimeRequestFromUser([FromBody] BugTimeRequestFromUserCommand command) { var res = await _mediator.Send(command); return res; } }