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