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