using FastEndpoints; using FrameworkBLL.DocumentSet; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.DocumentSet { public class GetDocumentSet : BaseEndpoint //Inheritance { private readonly IDocumentSetBLL _idocumentsetBLL; //Encapsulation & I Interface Implementation public GetDocumentSet(IDocumentSetBLL IDocumentSetBLL) { _idocumentsetBLL = IDocumentSetBLL; } public override void Configure() //Abstraction &Polymorphism { Get("/DocumentSet/GetDocumentSet"); AllowAnonymous(); } public record GetDocumentSetParameters( [property: QueryParam] int DocumentSetId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetDocumentSetParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.DocumentSetId!, EntityConstant.OBJECTDOCUMENTSET, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetDocumentSetParameters DocumentSetParameter, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _idocumentsetBLL.GetDocumentSet(DocumentSetParameter.DocumentSetId, 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); } } } }