using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Party; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Party { public class GetPartyDetailsQualityParameter : BaseEndpoint> { private readonly IPartyBLL _partyBLL; public GetPartyDetailsQualityParameter(IPartyBLL partyBLL) { _partyBLL = partyBLL; } public override void Configure() { Post("/Party/GetPartyDetailsQualityParameter"); AllowAnonymous(); } public record GetPartyDetailsQualityParameterRequest( [property: FromHeader] string Login, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync( GetPartyDetailsQualityParameterRequest req, LoginDTO loginDTO, CancellationToken ct) { try { if (req.CriteriaDTO?.SectionCriteriaList == null || req.CriteriaDTO.SectionCriteriaList.Count == 0) return await GB5Shared.ResponseStandard.Response.CreateExceptionError( new ArgumentException("CriteriaDTO must contain at least one SectionCriteriaList entry."), CacheKeyLevel.NOT_REQUIRED, loginDTO, "Please provide valid criteria to fetch party quality parameters.", 400); var result = await _partyBLL.GetPartyDetailsQualityParameter( req.FirstNumber, req.MaxResult, req.CriteriaDTO, loginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (ArgumentException ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 400); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }