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