72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
using PartSource.Entities.Nexpart;
|
|
using PartSource.Services;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Http;
|
|
|
|
namespace PartSource.Controllers
|
|
{
|
|
[RoutePrefix("parts")]
|
|
public class PartsController : BaseNexpartController
|
|
{
|
|
private readonly NexpartService _nexpartService;
|
|
|
|
public PartsController(NexpartService nexpartService)
|
|
{
|
|
this._nexpartService = nexpartService;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("PartNumber/{partNumber}/LineCode/{lineCode}")]
|
|
public IHttpActionResult GetPart(string partNumber, string lineCode)
|
|
{
|
|
new SmartPageDataSearch().Items = new Item[1]
|
|
{
|
|
new Item()
|
|
{
|
|
PartNumber = partNumber.ToUpperInvariant(),
|
|
MfrCode = lineCode.ToUpperInvariant()
|
|
}
|
|
};
|
|
return (IHttpActionResult)this.Ok();
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("search/basevehicleid/{baseVehicleId}")]
|
|
public async Task<IHttpActionResult> Search(uint baseVehicleId, [FromUri] string query)
|
|
{
|
|
PartsController partsController = this;
|
|
PartTypeSearch requestContent = new PartTypeSearch()
|
|
{
|
|
SearchString = query,
|
|
SearchType = "ALL",
|
|
SearchOptions = "PARTIAL_MATCH",
|
|
VehicleIdentifier = new VehicleIdentifier()
|
|
{
|
|
BaseVehicleId = baseVehicleId
|
|
}
|
|
};
|
|
PartTypeSearchResponse response = await partsController._nexpartService.SendRequest<PartTypeSearch, PartTypeSearchResponse>(requestContent);
|
|
return partsController.NexpartResponse<PartTypeSearchResponse, PartTypes>(response);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("validate/partTypeId/{partTypeId}/baseVehicleId/{baseVehicleId}")]
|
|
public async Task<IHttpActionResult> ValidatePartFitment(uint partTypeId, uint baseVehicleId)
|
|
{
|
|
PartsController partsController = this;
|
|
PartTypesValidateLookup typesValidateLookup = new PartTypesValidateLookup();
|
|
typesValidateLookup.PartTypes = new PartType[1]
|
|
{
|
|
new PartType() { Id = partTypeId }
|
|
};
|
|
typesValidateLookup.VehicleIdentifier = new VehicleIdentifier()
|
|
{
|
|
BaseVehicleId = baseVehicleId
|
|
};
|
|
PartTypesValidateLookup requestContent = typesValidateLookup;
|
|
PartTypesValidateLookupResponse response = await partsController._nexpartService.SendRequest<PartTypesValidateLookup, PartTypesValidateLookupResponse>(requestContent);
|
|
return partsController.NexpartResponse<PartTypesValidateLookupResponse, PartTypes>(response);
|
|
}
|
|
}
|
|
}
|