using FastEndpoints; using FrameworkBLL.City; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.City { public class DeleteCity : BaseEndpoint> { private readonly ICityBLL _CityBLL; public DeleteCity(ICityBLL ICityBLL) { _CityBLL = ICityBLL; } public override void Configure() { Delete("/City/DeleteCity"); AllowAnonymous(); } public record DeleteCityParameters( [property: FromHeader] string Login, [property: QueryParam] int CityId ); protected override async Task> ExecuteAsync(DeleteCityParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CityBLL.DeleteCity(req.CityId, 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); } } } }