.
This commit is contained in:
@@ -19,12 +19,29 @@ namespace PartSource.Api.Controllers
|
||||
private readonly NexpartService _nexpartService;
|
||||
private readonly PartService _partService;
|
||||
private readonly VehicleService _vehicleService;
|
||||
private readonly FitmentService _fitmentService;
|
||||
|
||||
public PartsController(NexpartService nexpartService, PartService partService, VehicleService vehicleService)
|
||||
public PartsController(NexpartService nexpartService, PartService partService, VehicleService vehicleService, FitmentService fitmentService)
|
||||
{
|
||||
_nexpartService = nexpartService;
|
||||
_partService = partService;
|
||||
_vehicleService = vehicleService;
|
||||
_fitmentService = fitmentService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("fitment")]
|
||||
[Route("fitmentnote")]
|
||||
public async Task<ActionResult> GetFitment([FromQuery] string sku, [FromQuery] int vehicleId)
|
||||
{
|
||||
VehicleFitmentDto vehicleFitment = await _fitmentService.GetFitmentNotes(sku, vehicleId);
|
||||
|
||||
if (vehicleFitment == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(vehicleFitment);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -34,31 +51,22 @@ namespace PartSource.Api.Controllers
|
||||
Part part = await _partService.GetPartBySku(sku);
|
||||
Vehicle vehicle = await _vehicleService.GetVehicleById(vehicleId);
|
||||
|
||||
if (part == null)
|
||||
if (part == null || vehicle == null)
|
||||
{
|
||||
return BadRequest(new
|
||||
{
|
||||
Message = $"No part data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.",
|
||||
Message = $"No data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.",
|
||||
Reason = $"{nameof(_partService.GetPartBySku)} returned null"
|
||||
});
|
||||
}
|
||||
|
||||
if (vehicle == null)
|
||||
{
|
||||
return BadRequest(new
|
||||
{
|
||||
Message = $"No vehicle data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.",
|
||||
Reason = $"{nameof(_vehicleService.GetVehicleById)} returned null"
|
||||
});
|
||||
}
|
||||
|
||||
IList<DcfMapping> mappings = await _partService.GetDcfMapping(part.LineCode);
|
||||
Item[] items = mappings.Select(m => new Item
|
||||
{
|
||||
PartNumber = part.PartNumber,
|
||||
MfrCode = m.WhiCode
|
||||
})
|
||||
.ToArray();
|
||||
{
|
||||
PartNumber = part.PartNumber,
|
||||
MfrCode = m.WhiCode
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch
|
||||
{
|
||||
@@ -76,9 +84,9 @@ namespace PartSource.Api.Controllers
|
||||
}
|
||||
|
||||
PartType[] partTypes = smartPageResponse.ResponseBody.Item.Select(i => new PartType
|
||||
{
|
||||
Id = i.Part.PartType.Id
|
||||
})
|
||||
{
|
||||
Id = i.Part.PartType.Id
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
ApplicationSearch applicationSearch = new ApplicationSearch
|
||||
|
||||
Reference in New Issue
Block a user