using FastEndpoints; using FrameworkBLL.Country; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Country { public class DeleteCountry : BaseEndpoint> { public readonly ICountryBLL _CountryBLL; public DeleteCountry(ICountryBLL ICountryBLL) { _CountryBLL = ICountryBLL; } public override void Configure() { Delete("/Country/DeleteCountry"); AllowAnonymous(); } public record DeleteCountryParameters( [property: FromHeader] string Login, [property: QueryParam] int CountryId ); protected override async Task> ExecuteAsync(DeleteCountryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CountryBLL.DeleteCountry(req.CountryId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }