using AdminBLL.AllocationType; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.AllocationType { public class GetAllocationType : BaseEndpoint> { private readonly IAllocationTypeBLL _AllocationTypeBLL; public GetAllocationType(IAllocationTypeBLL IAllocationTypeBLL) { _AllocationTypeBLL = IAllocationTypeBLL; } public override void Configure() { Get("/AllocationType/GetAllocationType"); AllowAnonymous(); } public record GetAllocationTypeParameters( [property: FromHeader] string Login, [property: QueryParam] int AllocationTypeId ); protected override string? GetCacheKey(GetAllocationTypeParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.AllocationTypeId!, EntityConstant.OBJECTALLOCATION, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetAllocationTypeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AllocationTypeBLL.GetAllocationType(req.AllocationTypeId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }