using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.VendorComparison; using MMDAL.DTO.VendorComparison; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.VendorComparison { // Ported from GB4 MMHead.svc "/Update/VendorDetail/?ItemPartyId={ItemPartyId}" // (IMMHead.UpdateVendorDetail / MMHeadBLL.UpdateVendorDetail) — updates // MITEMPARTY.PARTYSTATUS/SHAREPERCENTAGE for one ItemPartyId. public class UpdateVendorDetail : BaseEndpoint> { private readonly IVendorComparisonBLL _VendorComparisonBLL; public UpdateVendorDetail(IVendorComparisonBLL VendorComparisonBLL) { _VendorComparisonBLL = VendorComparisonBLL; } public override void Configure() { Post("/VendorComparison/UpdateVendorDetail"); AllowAnonymous(); } public record UpdateVendorDetailParameters( [property: FromHeader] string Login, [property: FromBody] VendorComparisonUpdateDTO VendorComparisonUpdateDTO, [property: QueryParam] int ItemPartyId ); protected override async Task> ExecuteAsync(UpdateVendorDetailParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { // ItemPartyId is the URL identifier (matches GB4's UriTemplate); the SL layer // is the one place that combines it with the body into the single DTO the BLL takes. req.VendorComparisonUpdateDTO.ItemPartyId = req.ItemPartyId; var Result = await _VendorComparisonBLL.UpdateVendorDetail(req.VendorComparisonUpdateDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }