using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Pattern; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Pattern { public class DeletePattern : BaseEndpoint> { private readonly IPatternBLL _PatternBLL; public DeletePattern(IPatternBLL IPatternBLL) { _PatternBLL = IPatternBLL; } public override void Configure() { Delete("/Pattern/DeletePattern"); AllowAnonymous(); } public record DeletePatternParameters( [property: FromHeader] string Login, [property: QueryParam] int PatternId ); protected override async Task> ExecuteAsync(DeletePatternParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PatternBLL.DeletePattern(req.PatternId, 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); } } } }