using FastEndpoints; using FrameworkBLL.WorkflowAssignment; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.WorkflowAssignment { public class GetWorkflowAssignment : BaseEndpoint { private readonly IWorkflowAssignmentBLL _WorkflowAssignmentBLL; public GetWorkflowAssignment(IWorkflowAssignmentBLL WorkflowAssignmentBLL) { _WorkflowAssignmentBLL = WorkflowAssignmentBLL; } public override void Configure() { Get("/WorkflowAssignment/GetWorkflowAssignment"); AllowAnonymous(); } public record GetWorkflowAssignmentParameters( [property: QueryParam] int WorkflowAssignmentId, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync( GetWorkflowAssignmentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _WorkflowAssignmentBLL.GetWorkflowAssignment( req.WorkflowAssignmentId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }