using ECPBLL.Shared.Interfaces; using ECPSL.Shared.Parameters; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace ECPSL.Shared.Endpoints.ObjectRegistry; /// Every active, registered object TYPE (MENTITY row) a comment/correspondence/task can /// be polymorphically linked to — see IObjectRegistryBLL's doc-comment for the type-vs-record /// scope note. public class GetSelectListObjectRegistry : BaseEndpoint> { private readonly IObjectRegistryBLL _bll; public GetSelectListObjectRegistry(IObjectRegistryBLL bll) => _bll = bll; public override void Configure() { Post("/ObjectRegistry/GetSelectListObjectRegistry"); AllowAnonymous(); } protected override string? GetCacheKey(GetSelectListObjectRegistryParameters req, LoginDTO login) => KeyGenerator.KeyGeneration( req.CriteriaDTO?.SearchKeyword ?? "all", EntityConstant.OBJECTOBJECTREGISTRYSELECTLIST, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( GetSelectListObjectRegistryParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetSelectListObjectRegistryAsync(req.CriteriaDTO?.SearchKeyword, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }