using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.PartnerProduct; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerProduct { public class DeletePartnerProduct : BaseEndpoint> { private readonly IPartnerProductBLL _partnerProductBLL; public DeletePartnerProduct(IPartnerProductBLL partnerProductBLL) => _partnerProductBLL = partnerProductBLL; public override void Configure() { Delete("/PartnerProduct/DeletePartnerProduct"); AllowAnonymous(); } public record DeletePartnerProductParameters( [property: FromHeader] string Login, [property: QueryParam] int PartnerProductId ); protected override string? GetCacheKey(DeletePartnerProductParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( DeletePartnerProductParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _partnerProductBLL.DeletePartnerProduct(req.PartnerProductId, 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); } } } }