This commit is contained in:
2023-12-19 14:49:30 -05:00
parent b8406a7f71
commit aed30707be
17 changed files with 184 additions and 60 deletions

View File

@@ -41,6 +41,66 @@ namespace PartSource.Api.Controllers
return NotFound();
}
Item[] items = new[]
{
new Item { PartNumber = vehicleFitment.PartNumber, MfrCode = vehicleFitment.LineCode }
};
SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch
{
Items = items
};
SmartPageDataSearchResponse smartPageResponse = await _nexpartService.SendRequest<SmartPageDataSearch, SmartPageDataSearchResponse>(smartPageDataSearch);
if (smartPageResponse.ResponseBody?.Item != null)
{
PartType[] partTypes = smartPageResponse.ResponseBody.Item.Select(i => new PartType
{
Id = i.Part.PartType.Id
})
.ToArray();
ApplicationSearch applicationSearch = new ApplicationSearch
{
VehicleIdentifier = new VehicleIdentifier
{
BaseVehicleId = vehicleFitment.BaseVehicleId,
EngineConfigId = vehicleFitment.EngineConfigId
},
MfrCode = new[] { vehicleFitment.LineCode },
PartType = partTypes,
GroupBy = "MFR",
QuestionOption = "QUESTION_OTHERWISE_APP"
};
ApplicationSearchResponse response = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
if (response.ResponseBody != null)
{
vehicleFitment.DriveTypes = new List<string>();
Question driveTypeQuestion = ((Questions)response.ResponseBody).Question
.Where(q => q.Attribute == "DRIVE_TYPE")
.FirstOrDefault();
if (driveTypeQuestion != null)
{
foreach (Answer answer in driveTypeQuestion.Answer)
{
applicationSearch.Criterion = new[]
{
new Criterion { Attribute = "DRIVE_TYPE", Id = answer.Id}
};
ApplicationSearchResponse driveTypeResponse = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
if (driveTypeResponse.ResponseBody != null && ((Apps)driveTypeResponse.ResponseBody).App.Where(a => a.Part == vehicleFitment.PartNumber).Any())
{
vehicleFitment.DriveTypes.Add(answer.Value);
}
}
}
}
}
return Ok(vehicleFitment);
}
@@ -75,7 +135,7 @@ namespace PartSource.Api.Controllers
PartNumber = part.PartNumber,
MfrCode = m.WhiCode
})
.ToArray();
.ToArray();
SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch
{
@@ -96,7 +156,7 @@ namespace PartSource.Api.Controllers
{
Id = i.Part.PartType.Id
})
.ToArray();
.ToArray();
ApplicationSearch applicationSearch = new ApplicationSearch
{
@@ -129,7 +189,7 @@ namespace PartSource.Api.Controllers
}
IList<string> positions = new List<string>();
foreach (App app in response.ResponseBody?.App)
foreach (App app in ((Apps)response.ResponseBody)?.App)
{
if (!string.IsNullOrEmpty(app.Position) && app.Part == part.PartNumber)
{