using FastEndpoints; using FrameworkBLL.Picklist; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Picklist { public class GetPicklist : BaseEndpoint { private readonly IPicklistBLL _picklistBLL; public GetPicklist(IPicklistBLL picklistBLL) { _picklistBLL = picklistBLL; } public override void Configure() { Get("/Picklist/GetPicklist"); AllowAnonymous(); } public record GetPicklistParameters( [property: QueryParam] int PicklistId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetPicklistParameters GetPicklistParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetPicklistParameters.PicklistId!, EntityConstant.OBJECTPICKLIST, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetPicklistParameters parameter, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _picklistBLL.GetPicklist(parameter.PicklistId, 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); } } } }