93 lines
3.3 KiB
C#
93 lines
3.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using PartSource.Data.Dtos;
|
|
using PartSource.Data.Models;
|
|
using PartSource.Data.Nexpart;
|
|
using PartSource.Services;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Http;
|
|
|
|
namespace PartSource.Api.Controllers
|
|
{
|
|
[Route("[controller]")]
|
|
[ApiController]
|
|
public class PartsController : BaseNexpartController
|
|
{
|
|
private readonly NexpartService _nexpartService;
|
|
private readonly PartService _partService;
|
|
|
|
public PartsController(NexpartService nexpartService, PartService partService)
|
|
{
|
|
this._nexpartService = nexpartService;
|
|
_partService = partService;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("PartNumber/{partNumber}/LineCode/{lineCode}")]
|
|
public ActionResult GetPart(string partNumber, string lineCode)
|
|
{
|
|
new SmartPageDataSearch().Items = new Item[1]
|
|
{
|
|
new Item()
|
|
{
|
|
PartNumber = partNumber.ToUpperInvariant(),
|
|
MfrCode = lineCode.ToUpperInvariant()
|
|
}
|
|
};
|
|
return (ActionResult)this.Ok();
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("search/basevehicleid/{baseVehicleId}")]
|
|
public async Task<ActionResult> Search(int baseVehicleId, [FromQuery] 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<ActionResult> ValidatePartFitment(int partTypeId, int 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);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("search/fitment")]
|
|
public async Task<ActionResult> FitmentSearch([FromQuery] FitmentSearchDto fitmentSearchDto)
|
|
{
|
|
IList<Fitment> fitments = _partService.GetFitments(fitmentSearchDto);
|
|
|
|
if (fitments == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(new { Data = fitments });
|
|
}
|
|
}
|
|
}
|