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