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