using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; using TMSBLL.EvaluationPlan; namespace TMSSL.EndPoints.EvaluationPlan { public class DeleteEvaluationPlan : BaseEndpoint> { private readonly IEvaluationPlanBLL _EvaluationBLL; public DeleteEvaluationPlan(IEvaluationPlanBLL evaluationBLL) { _EvaluationBLL = evaluationBLL; } public override void Configure() { Delete("/EvaluationPlan/DeleteEvaluationPlan"); AllowAnonymous(); } public record DeleteEvaluationPlanParameters( [property: QueryParam] int EvalPlanId, [property: FromHeader] string Login ); protected override string? GetCacheKey(DeleteEvaluationPlanParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.EvalPlanId, EntityConstant.OBJECTEVALUATIONPLAN, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override bool ShouldInvalidateCache(DeleteEvaluationPlanParameters req, LoginDTO loginDTO) => true; protected override async Task> ExecuteAsync(DeleteEvaluationPlanParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _EvaluationBLL.DeleteEvaluationPlan(req.EvalPlanId, 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); } } } }