using FastEndpoints; using FrameworkBLL.AssetAssignment; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.AssetAssignment { public class GetAssetAssignment : BaseEndpoint> { private readonly IAssetAssignmentBLL _AssetAssignmentBLL; public GetAssetAssignment(IAssetAssignmentBLL IAssetAssignmentBLL) { _AssetAssignmentBLL = IAssetAssignmentBLL; } public override void Configure() { Get("/AssetAssignment/GetAssetAssignment"); AllowAnonymous(); } public record GetAssetAssignmentParameters( [property: FromHeader] string Login, [property: QueryParam] int AssetAssignmentId ); protected override string? GetCacheKey(GetAssetAssignmentParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.AssetAssignmentId!, EntityConstant.OBJECTMASSETASSIGNMENT, FrameworkDAL.Constant.Constant.CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetAssetAssignmentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AssetAssignmentBLL.GetAssetAssignment(req.AssetAssignmentId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, FrameworkDAL.Constant.Constant.CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, FrameworkDAL.Constant.Constant.CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }