using FastEndpoints; using FrameworkBLL.GCM; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.GCM { public class DeleteGCM : BaseEndpoint> { private readonly IGCMBLL _GCMBLL; public DeleteGCM(IGCMBLL GCMBLL) { _GCMBLL = GCMBLL; } public override void Configure() { Delete("/GCM/DeleteGCM"); AllowAnonymous(); } public record DeleteGCMParameters( [property: FromHeader] string Login, [property: QueryParam] int GCMId ); protected override string? GetCacheKey(DeleteGCMParameters req, LoginDTO LoginDTO) { return KeyGenerator.KeyGeneration(req.GCMId, EntityConstant.OBJECTGCM, CacheKeyLevel.USER_LEVEL, LoginDTO); } protected override bool ShouldInvalidateCache(DeleteGCMParameters req, LoginDTO LoginDTO) => true; protected override async Task> ExecuteAsync(DeleteGCMParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _GCMBLL.DeleteGCM(req.GCMId, 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); } } } }