using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Village; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Village { public class DeleteVillage : BaseEndpoint> { private readonly IVillageBLL _VillageBLL; public DeleteVillage(IVillageBLL villageBLL) { _VillageBLL = villageBLL; } public override void Configure() { Delete("/Village/DeleteVillage"); AllowAnonymous(); } public record DeleteVillageParameters( [property: FromHeader] string Login, [property: QueryParam] int VillageId ); protected override string? GetCacheKey(DeleteVillageParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( DeleteVillageParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _VillageBLL.DeleteVillage(req.VillageId, 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); } } } }