using CRMBLL.Task; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace CRMSL.EndPoints.Task { public class GenerateTask : BaseEndpoint> { private readonly ITaskBLL _TaskBLL; public GenerateTask(ITaskBLL TaskBLL) => _TaskBLL = TaskBLL; public override void Configure() { Post("/Task/GenerateTask"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] DateOnly ToDate, [property: QueryParam] byte TaskNature, [property: FromBody] CriteriaDTO? CriteriaDTO ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _TaskBLL.GenerateTask( req.ToDate, req.TaskNature, req.CriteriaDTO ?? new CriteriaDTO(), LoginDTO); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }