add workflow controller

This commit is contained in:
2026-01-24 14:02:18 +03:30
parent 7e563a0f01
commit 15f1c938f7
3 changed files with 89 additions and 1 deletions

View File

@@ -49,7 +49,8 @@ public class TaskRevisionsByTaskSectionIdQueryHandler : IBaseQueryHandler<TaskRe
{ {
var itemFileIds = x.Files.Select(f => f.FileId).Distinct().ToList(); var itemFileIds = x.Files.Select(f => f.FileId).Distinct().ToList();
var files = uploadedFiles.Where(f => itemFileIds.Contains(f.Id)) var files = uploadedFiles
.Where(f => itemFileIds.Contains(f.Id))
.Select(file => new TaskRevisionsByTaskSectionIdItemFile() .Select(file => new TaskRevisionsByTaskSectionIdItemFile()
{ {
Id = file.Id, Id = file.Id,

View File

@@ -0,0 +1,62 @@
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
using Microsoft.EntityFrameworkCore;
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
public record WorkflowListResponse(List<WorkflowListItem>Items);
public class WorkflowListItem
{
public string Title { get; set; }
public WorkflowType Type { get; set; }
public Guid EntityId { get; set; }
}
public enum WorkflowType
{
Rejected,
NotAssigned,
PendingForApproval,
}
public record WorkflowListQuery():IBaseQuery<WorkflowListResponse>;
public class WorkflowListQueryHandler:IBaseQueryHandler<WorkflowListQuery,WorkflowListResponse>
{
private readonly IProgramManagerDbContext _context;
private readonly IAuthHelper _authHelper;
public WorkflowListQueryHandler(IProgramManagerDbContext context,
IAuthHelper authHelper)
{
_context = context;
_authHelper = authHelper;
}
public async Task<OperationResult<WorkflowListResponse>> Handle(WorkflowListQuery request, CancellationToken cancellationToken)
{
var currentUserId =_authHelper.GetCurrentUserId();
var query = await (from revision in _context.TaskSectionRevisions
.Where(x=>x.Status == RevisionReviewStatus.Pending)
join taskSection in _context.TaskSections.Where(x => x.CurrentAssignedUserId == currentUserId)
on revision.TaskSectionId equals taskSection.Id
select new
{
taskSection,
revision
}).ToListAsync(cancellationToken: cancellationToken);
var workflowListItems = query.Select(x=>new WorkflowListItem()
{
EntityId = x.taskSection.Id,
Title = "برگشت از سمت مدیر",
Type = WorkflowType.Rejected
}).ToList();
var res = new WorkflowListResponse(workflowListItems);
return OperationResult<WorkflowListResponse>.Success(res);
}
}

View File

@@ -0,0 +1,25 @@
using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Admin.Controllers.ProgramManager;
public class WorkflowController:ProgramManagerBaseController
{
private readonly IMediator _mediator;
public WorkflowController(IMediator mediator)
{
_mediator = mediator;
}
[HttpGet]
public async Task<ActionResult<OperationResult<WorkflowListResponse>>> Get(WorkflowListQuery query)
{
var res = await _mediator.Send(query);
return res;
}
}