Initial commit

This commit is contained in:
2020-04-12 20:52:03 -04:00
parent e750d2848a
commit 01e7627293
249 changed files with 9733 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
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 });
}
}
}