using FastEndpoints; using FMBLL.AssetType; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FMSL.EndPoints.AssetType { public class GetAssetType : BaseEndpoint> { private readonly IAssetTypeBLL _AssetTypeBLL; public GetAssetType(IAssetTypeBLL IAssetTypeBLL) { _AssetTypeBLL = IAssetTypeBLL; } public override void Configure() { Get("/AssetType/GetAssetType"); AllowAnonymous(); } public record GetAssetTypeParameters( [property: FromHeader] string Login, [property: QueryParam] int AssetTypeId ); //protected override string? GetCacheKey(GetAssetTypeParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.AssetTypeId!, EntityConstant.OBJECTASSETTYPE, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetAssetTypeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AssetTypeBLL.GetAssetType(req.AssetTypeId, LoginDTO!, ct); 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); } } } }