using AccountsBLL.PartyBranch; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.PartyBranch { public class DeletePartyBranch : BaseEndpoint> { private readonly IPartyBranchBLL _PartyBranchBLL; public DeletePartyBranch(IPartyBranchBLL IPartyBranchBLL) { _PartyBranchBLL = IPartyBranchBLL; } public override void Configure() { Delete("/PartyBranch/DeletePartyBranch"); AllowAnonymous(); } public record DeletePartyBranchParameters( [property: FromHeader] string Login, [property: QueryParam] int PartyBranchId ); protected override string? GetCacheKey(DeletePartyBranchParameters req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(DeletePartyBranchParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PartyBranchBLL.DeletePartyBranch(req.PartyBranchId, 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); } } } }