using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.MRPPartyType; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.MRPPartyType { public class GetMRPPartyType : BaseEndpoint> { private readonly IMRPPartyTypeBLL _MRPPartyTypeBLL; public GetMRPPartyType(IMRPPartyTypeBLL MRPPartyTypeBLL) { _MRPPartyTypeBLL = MRPPartyTypeBLL; } public override void Configure() { Get("/MRPPartyType/GetMRPPartyType"); AllowAnonymous(); } public record GetMRPPartyTypeParameters( [property: QueryParam] int MRPPartyTypeId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetMRPPartyTypeParameters parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(parameters.MRPPartyTypeId!, EntityConstant.OBJECTMRPPARTYTYPE, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetMRPPartyTypeParameters parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _MRPPartyTypeBLL.GetMRPPartyType(parameters.MRPPartyTypeId, 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); } } } }