using AdminBLL.OrganizationUnit; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.OrganizationUnit { public class GetOUCity : BaseEndpoint> { private readonly IOrganizationUnitBLL _OrganizationUnitBLL; public GetOUCity(IOrganizationUnitBLL organizationUnitBLL) { _OrganizationUnitBLL = organizationUnitBLL; } public override void Configure() { Get("/OrganizationUnit/GetOUCity"); AllowAnonymous(); } public record GetOUCityParameters( [property: FromHeader] string Login, [property: QueryParam] int OUId ); protected override string? GetCacheKey(GetOUCityParameters req, LoginDTO LoginDTO) => KeyGenerator.KeyGeneration(req.OUId, EntityConstant.OBJECTORGANIZATIONUNIT, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); protected override async Task> ExecuteAsync(GetOUCityParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _OrganizationUnitBLL.GetOUCity(req.OUId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }