using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.EvaluationTemplate; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.EvaluationTemplate { public class DeleteEvaluationTemplatesByPlan : BaseEndpoint> { private readonly IEvaluationTemplateBLL _EvaluationTemplateBLL; public DeleteEvaluationTemplatesByPlan(IEvaluationTemplateBLL evaluationTemplateBLL) { _EvaluationTemplateBLL = evaluationTemplateBLL; } public override void Configure() { Delete("/EvaluationTemplate/DeleteEvaluationTemplatesByPlan"); AllowAnonymous(); } public record Parameters( [property: QueryParam] int EvaluationPlanId, [property: FromHeader] string Login ); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _EvaluationTemplateBLL.DeleteEvaluationTemplatesByPlan(req.EvaluationPlanId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }