using FastEndpoints; using FrameworkBLL.BulkIce; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.BulkIce { public class GetBulkIce : BaseEndpoint { private readonly IBulkIceBLL _bulkIceBLL; public GetBulkIce(IBulkIceBLL bulkIceBLL) { _bulkIceBLL = bulkIceBLL; } public override void Configure() { Get("/BulkIce/GetBulkIce"); AllowAnonymous(); } public record GetBulkIceParameters( [property: QueryParam] int BulkIceId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetBulkIceParameters GetBulkIceParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetBulkIceParameters.BulkIceId!, EntityConstant.MBULKICE, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetBulkIceParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _bulkIceBLL.GetBulkIceData(parameters.BulkIceId, 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); } } } }