Initial commit
This commit is contained in:
36
PartSource.Api/Controllers/BaseNexpartController.cs
Normal file
36
PartSource.Api/Controllers/BaseNexpartController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: PartSource.Controllers.BaseNexpartController
|
||||
// Assembly: PartSource, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 9C95A003-DAA7-4079-9F59-D1FC80E1666C
|
||||
// Assembly location: C:\Users\Tommy\Desktop\PS temp\PartSource.dll
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PartSource.Data.Nexpart;
|
||||
using PartSource.Data.Nexpart.Interfaces;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
public class BaseNexpartController : ControllerBase
|
||||
{
|
||||
protected ActionResult NexpartResponse<T, U>(T response) where T : IResponseElement<U>
|
||||
{
|
||||
Exceptions[] exceptions = response.PSResponseHeader.Exceptions;
|
||||
if ((exceptions != null ? ((uint)exceptions.Length > 0U ? 1 : 0) : 0) == 0)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
Data = response.ResponseBody
|
||||
});
|
||||
}
|
||||
|
||||
string empty = string.Empty;
|
||||
foreach (Exceptions exception in response.PSResponseHeader.Exceptions)
|
||||
empty += string.Format("{0}\n", (object)exception.Value);
|
||||
|
||||
return BadRequest(new
|
||||
{
|
||||
Data = response.ResponseBody
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
33
PartSource.Api/Controllers/ErrorController.cs
Normal file
33
PartSource.Api/Controllers/ErrorController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
public class ErrorController : ControllerBase
|
||||
{
|
||||
[Route("")]
|
||||
[AllowAnonymous]
|
||||
public ActionResult Get()
|
||||
{
|
||||
IExceptionHandlerPathFeature exceptionFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
|
||||
|
||||
if (exceptionFeature != null)
|
||||
{
|
||||
string route = exceptionFeature.Path;
|
||||
|
||||
Exception ex = exceptionFeature.Error;
|
||||
|
||||
//TODO: Logging
|
||||
}
|
||||
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
PartSource.Api/Controllers/InventoryController.cs
Normal file
43
PartSource.Api/Controllers/InventoryController.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PartSource.Data.Models;
|
||||
using PartSource.Services;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class InventoryController : BaseNexpartController
|
||||
{
|
||||
private readonly PartService _inventoryService;
|
||||
|
||||
public InventoryController(PartService inventoryService)
|
||||
{
|
||||
_inventoryService = inventoryService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("sku/{sku}/storeNumber/{storeNumber}")]
|
||||
public async Task<ActionResult> GetInventory(int sku, int storeNumber)
|
||||
{
|
||||
PartsAvailability inventory = _inventoryService.GetInventory(sku, storeNumber);
|
||||
|
||||
if (inventory == null)
|
||||
{
|
||||
return NotFound($"No part matching SKU {sku} was found.");
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
data = new
|
||||
{
|
||||
StoreNumber = inventory.Store,
|
||||
Sku = sku,
|
||||
Quantity = inventory.QTY
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
159
PartSource.Api/Controllers/NexpartVehiclesController.cs
Normal file
159
PartSource.Api/Controllers/NexpartVehiclesController.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PartSource.Data.Nexpart;
|
||||
using PartSource.Services;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class NexpartVehiclesController : BaseNexpartController
|
||||
{
|
||||
private readonly NexpartService _nexpartService;
|
||||
|
||||
public NexpartVehiclesController(NexpartService nexpartService)
|
||||
{
|
||||
this._nexpartService = nexpartService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("types")]
|
||||
public async Task<ActionResult> GetVehicleTypes()
|
||||
{
|
||||
NexpartVehiclesController vehiclesController = this;
|
||||
VehicleTypesGetResponse response = await vehiclesController._nexpartService.SendRequest<VehicleTypesGet, VehicleTypesGetResponse>(new VehicleTypesGet());
|
||||
return vehiclesController.NexpartResponse<VehicleTypesGetResponse, VehicleTypes>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes")]
|
||||
public async Task<ActionResult> GetMakes()
|
||||
{
|
||||
NexpartVehiclesController vehiclesController = this;
|
||||
MakeSearch requestContent = new MakeSearch()
|
||||
{
|
||||
VehicleTypeId = new int[] { 5, 6, 7 }
|
||||
};
|
||||
MakeSearchResponse response = await vehiclesController._nexpartService.SendRequest<MakeSearch, MakeSearchResponse>(requestContent);
|
||||
return vehiclesController.NexpartResponse<MakeSearchResponse, Makes>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes/vehicletypeid/{vehicleTypeId}")]
|
||||
public async Task<ActionResult> GetMakes(int vehicleTypeId)
|
||||
{
|
||||
NexpartVehiclesController vehiclesController = this;
|
||||
MakeSearch requestContent = new MakeSearch()
|
||||
{
|
||||
VehicleTypeId = new int[] { vehicleTypeId }
|
||||
};
|
||||
MakeSearchResponse response = await vehiclesController._nexpartService.SendRequest<MakeSearch, MakeSearchResponse>(requestContent);
|
||||
return vehiclesController.NexpartResponse<MakeSearchResponse, Makes>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("models/makeid/{makeId}/modelyear/{year}")]
|
||||
public async Task<ActionResult> GetModels(int makeId, int year)
|
||||
{
|
||||
NexpartVehiclesController vehiclesController = this;
|
||||
ModelSearch requestContent = new ModelSearch()
|
||||
{
|
||||
MakeId = makeId,
|
||||
Year = year,
|
||||
VehicleTypeId = new int[] { 5, 6, 7 }
|
||||
};
|
||||
ModelSearchResponse response = await vehiclesController._nexpartService.SendRequest<ModelSearch, ModelSearchResponse>(requestContent);
|
||||
return vehiclesController.NexpartResponse<ModelSearchResponse, Models[]>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("models/makeid/{makeId}/modelyear/{year}/vehicletypeid/{vehicleTypeId}")]
|
||||
public async Task<ActionResult> GetModels(int makeId, int year, int vehicleTypeId)
|
||||
{
|
||||
NexpartVehiclesController vehiclesController = this;
|
||||
ModelSearch requestContent = new ModelSearch()
|
||||
{
|
||||
MakeId = makeId,
|
||||
Year = year,
|
||||
VehicleTypeId = new int[] { vehicleTypeId }
|
||||
};
|
||||
ModelSearchResponse response = await vehiclesController._nexpartService.SendRequest<ModelSearch, ModelSearchResponse>(requestContent);
|
||||
return vehiclesController.NexpartResponse<ModelSearchResponse, Models[]>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("basevehicle/makeid/{makeId}/modelid/{modelId}/modelyear/{year}")]
|
||||
public async Task<ActionResult> GetBaseVehicle(int makeId, int modelId, int year)
|
||||
{
|
||||
BaseVehicleDetailLookup requestContent = new BaseVehicleDetailLookup()
|
||||
{
|
||||
MakeId = makeId,
|
||||
ModelId = modelId,
|
||||
Year = year
|
||||
};
|
||||
BaseVehicleDetailLookupResponse response = await _nexpartService.SendRequest<BaseVehicleDetailLookup, BaseVehicleDetailLookupResponse>(requestContent);
|
||||
return NexpartResponse<BaseVehicleDetailLookupResponse, BaseVehicleDetail>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("engines/basevehicleid/{baseVehicleId}")]
|
||||
[Route("engines/basevehicleid/{baseVehicleId}/submodelid/{subModelId}")]
|
||||
public async Task<ActionResult> GetEngines(int baseVehicleId, int? subModelId = null)
|
||||
{
|
||||
EngineSearch requestContent = new EngineSearch()
|
||||
{
|
||||
VehicleIdentifier = new VehicleIdentifier()
|
||||
{
|
||||
BaseVehicleId = baseVehicleId
|
||||
},
|
||||
SubModelId = subModelId
|
||||
};
|
||||
EngineSearchResponse response = await _nexpartService.SendRequest<EngineSearch, EngineSearchResponse>(requestContent);
|
||||
return NexpartResponse<EngineSearchResponse, Engines>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("trim/makeid/{makeId}/modelid/{modelId}/modelyear/{year}")]
|
||||
public async Task<ActionResult> GetTrim(int makeId, int modelId, int year)
|
||||
{
|
||||
SubModelSearch requestContent = new SubModelSearch()
|
||||
{
|
||||
MakeId = makeId,
|
||||
ModelId = modelId,
|
||||
Year = year,
|
||||
RegionId = 2
|
||||
};
|
||||
SubModelSearchResponse response = await _nexpartService.SendRequest<SubModelSearch, SubModelSearchResponse>(requestContent);
|
||||
return NexpartResponse<SubModelSearchResponse, SubModels>(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/detail/basevehicleid/{baseVehicleId}/submodelid/{subModelId}/engineconfigid/{engineConfigId}")]
|
||||
public async Task<ActionResult> GetVehicleId(int baseVehicleId, int subModelId, int engineConfigId)
|
||||
{
|
||||
VehicleIdSearch requestContent = new VehicleIdSearch
|
||||
{
|
||||
VehicleIdentifier = new VehicleIdentifier()
|
||||
{
|
||||
BaseVehicleId = baseVehicleId,
|
||||
EngineConfigId = engineConfigId
|
||||
},
|
||||
Criterion = new Criterion[1]{
|
||||
new Criterion
|
||||
{
|
||||
Attribute = "SUB_MODEL",
|
||||
Id = subModelId
|
||||
}
|
||||
},
|
||||
RegionId = new RegionId
|
||||
{
|
||||
Value = 2
|
||||
},
|
||||
};
|
||||
|
||||
VehicleIdSearchResponse response = await _nexpartService.SendRequest<VehicleIdSearch, VehicleIdSearchResponse>(requestContent);
|
||||
return NexpartResponse<VehicleIdSearchResponse, VehicleDetail>(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
PartSource.Api/Controllers/PartsController.cs
Normal file
92
PartSource.Api/Controllers/PartsController.cs
Normal 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
32
PartSource.Api/Controllers/SearchController.cs
Normal file
32
PartSource.Api/Controllers/SearchController.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PartSource.Data.Nexpart;
|
||||
using PartSource.Services;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class SearchController : BaseNexpartController
|
||||
{
|
||||
private readonly NexpartService _nexpartService;
|
||||
|
||||
public SearchController()
|
||||
{
|
||||
this._nexpartService = new NexpartService();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes/vehicletypeid/{vehicleTypeId}")]
|
||||
public async Task<ActionResult> GetMakes(int vehicleTypeId)
|
||||
{
|
||||
SearchController searchController = this;
|
||||
MakeSearch requestContent = new MakeSearch()
|
||||
{
|
||||
VehicleTypeId = new int[] { vehicleTypeId }
|
||||
};
|
||||
MakeSearchResponse response = await searchController._nexpartService.SendRequest<MakeSearch, MakeSearchResponse>(requestContent);
|
||||
return searchController.NexpartResponse<MakeSearchResponse, Makes>(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
47
PartSource.Api/Controllers/StoresController.cs
Normal file
47
PartSource.Api/Controllers/StoresController.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
//using Microsoft.AspNetCore.Mvc;
|
||||
//using PartSource.Data.Models;
|
||||
//using PartSource.Services;
|
||||
//using System.Web.Http;
|
||||
|
||||
//namespace PartSource.Api.Controllers
|
||||
//{
|
||||
// [Route("stores")]
|
||||
// public class StoresController : ControllerBase
|
||||
// {
|
||||
// private const int Count = 5;
|
||||
// private const int Page = 1;
|
||||
// private readonly LocationService _service;
|
||||
|
||||
// public StoresController(LocationService service)
|
||||
// {
|
||||
// this._service = service;
|
||||
// }
|
||||
|
||||
// [HttpGet]
|
||||
// [Route("nearest/{postal}")]
|
||||
// [Route("nearest/{postal}/count/{count}")]
|
||||
// [Route("nearest/{postal}/count/{count}/page/{page}")]
|
||||
// public ActionResult GetNearestStores(string postal, int count = 5, int page = 1)
|
||||
// {
|
||||
// PostalCode postalCodeData = this._service.GetPostalCodeData(postal);
|
||||
// if (postalCodeData == null)
|
||||
// return (ActionResult)this.BadRequest("Invalid postal code");
|
||||
// return (ActionResult)this.Ok(new
|
||||
// {
|
||||
// Data = this._service.GetClosestLocations(postalCodeData, count, page)
|
||||
// });
|
||||
// }
|
||||
|
||||
// [HttpGet]
|
||||
// [Route("nearest/{postal}/radius/{radius}")]
|
||||
// [Route("nearest/{postal}/radius/{radius}/count/{count}")]
|
||||
// [Route("nearest/{postal}/radius/{radius}/count/{count}/page/{page}")]
|
||||
// public ActionResult GetNearestStores(string postal, double radius, int count = 5, int page = 1)
|
||||
// {
|
||||
// return (ActionResult)this.Ok(new
|
||||
// {
|
||||
// Data = this._service.GetClosestLocations(this._service.GetPostalCodeData(postal), count, page, radius)
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
40
PartSource.Api/Controllers/TemplatesController.cs
Normal file
40
PartSource.Api/Controllers/TemplatesController.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class TemplatesController : ControllerBase
|
||||
{
|
||||
|
||||
[Route("{templateName}/{vehicleId}")]
|
||||
[HttpGet]
|
||||
public IActionResult GetTemplate(string templateName, int vehicleId)
|
||||
{
|
||||
StringValues contentType = new StringValues("application/liquid");
|
||||
Response.Headers.Add("Content-Type", contentType);
|
||||
|
||||
string content = $"{templateName},{vehicleId}";
|
||||
|
||||
return Ok(content);
|
||||
}
|
||||
|
||||
//Crappy oauth code to make the app installable on shopify
|
||||
|
||||
//HttpRequest request = HttpContext.Request;
|
||||
|
||||
//string location = "https://ratermaniac.myshopify.com/admin/oauth/authorize?client_id=097de154602f28499e058f66b8653033&scope=read_customers&redirect_uri=https://soundpress.com&state=0.4585849384";
|
||||
|
||||
//StringValues locationHeader = new StringValues(location);
|
||||
|
||||
// //Response.Headers.Add("Location", location);
|
||||
|
||||
// return Redirect(location);
|
||||
}
|
||||
}
|
||||
101
PartSource.Api/Controllers/VehiclesController.cs
Normal file
101
PartSource.Api/Controllers/VehiclesController.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PartSource.Data.Models;
|
||||
using PartSource.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class VehiclesController : BaseNexpartController
|
||||
{
|
||||
private readonly VehicleService _vehicleService;
|
||||
|
||||
public VehiclesController(VehicleService vehicleService)
|
||||
{
|
||||
this._vehicleService = vehicleService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes")]
|
||||
public async Task<ActionResult> GetMakes()
|
||||
{
|
||||
IList<VehicleMake> makes = await _vehicleService.GetAllMakes();
|
||||
|
||||
return Ok(makes);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("models/makeid/{makeId}/modelyear/{year}")]
|
||||
public async Task<ActionResult> GetModels(int makeId, int year)
|
||||
{
|
||||
IList<VehicleData> models = await _vehicleService.GetModels(makeId, year);
|
||||
|
||||
return Ok(models);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("basevehicle/makeid/{makeId}/modelid/{modelId}/modelyear/{year}")]
|
||||
[Route("basevehicles/makeid/{makeId}/modelid/{modelId}/modelyear/{year}")]
|
||||
public async Task<ActionResult> GetBaseVehicle(int makeId, int modelId, int year)
|
||||
{
|
||||
IList<BaseVehicle> baseVehicles = await _vehicleService.GetBaseVehicles(makeId, modelId, year);
|
||||
|
||||
return Ok(baseVehicles);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("engines/basevehicleid/{baseVehicleId}")]
|
||||
[Route("engines/basevehicleid/{baseVehicleId}/submodelid/{subModelId}")]
|
||||
public async Task<ActionResult> GetEngines(int baseVehicleId, int? submodelId = null)
|
||||
{
|
||||
IList<Engine> engines = submodelId == null
|
||||
? await _vehicleService.GetEngines(baseVehicleId)
|
||||
: await _vehicleService.GetEngines(baseVehicleId, (int)submodelId);
|
||||
|
||||
return Ok(engines);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("trim/makeid/{makeId}/modelid/{modelId}/modelyear/{year}")]
|
||||
[Route("submodels/makeid/{makeId}/modelid/{modelId}/modelyear/{year}")]
|
||||
public async Task<ActionResult> GetSubmodels(int makeId, int modelId, int year)
|
||||
{
|
||||
IList<Submodel> submodels = await _vehicleService.GetSubmodels(makeId, modelId, year);
|
||||
|
||||
return Ok(submodels);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/detail/basevehicleid/{baseVehicleId}/submodelid/{submodelId}/engineconfigid/{engineConfigId}")]
|
||||
public async Task<ActionResult> GetVehicleDetail(int baseVehicleId, int submodelId, int engineConfigId)
|
||||
{
|
||||
VehicleData vehicle = await _vehicleService.GetVehicle(baseVehicleId, engineConfigId, submodelId);
|
||||
|
||||
return Ok(vehicle);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("types")]
|
||||
public ActionResult GetVehicleTypes()
|
||||
{
|
||||
return new StatusCodeResult((int)HttpStatusCode.Gone);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes/vehicletypeid/{vehicleTypeId}")]
|
||||
public ActionResult GetMakes(int vehicleTypeId)
|
||||
{
|
||||
return new StatusCodeResult((int)HttpStatusCode.Gone);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("models/makeid/{makeId}/modelyear/{year}/vehicletypeid/{vehicleTypeId}")]
|
||||
public ActionResult GetModels(int makeId, int year, int vehicleTypeId)
|
||||
{
|
||||
return new StatusCodeResult((int)HttpStatusCode.Gone);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
PartSource.Api/Formatters/LiquidTemplateOutputFormatter.cs
Normal file
28
PartSource.Api/Formatters/LiquidTemplateOutputFormatter.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Api.Formatters
|
||||
{
|
||||
public class LiquidTemplateOutputFormatter : TextOutputFormatter
|
||||
{
|
||||
public LiquidTemplateOutputFormatter()
|
||||
{
|
||||
SupportedMediaTypes.Add("application/liquid");
|
||||
SupportedEncodings.Add(Encoding.UTF8);
|
||||
SupportedEncodings.Add(Encoding.Unicode);
|
||||
}
|
||||
|
||||
protected override bool CanWriteType(Type type)
|
||||
{
|
||||
return type == typeof(string);
|
||||
}
|
||||
|
||||
public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
|
||||
{
|
||||
await context.HttpContext.Response.WriteAsync((string)context.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
PartSource.Api/PartSource.Api.csproj
Normal file
33
PartSource.Api/PartSource.Api.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UserSecretsId>f9e2fd37-0f2d-4e3a-955a-8e49a16fce1c</UserSecretsId>
|
||||
<Configurations>Debug;Release;Also Debug</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="appsettings.development.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="appsettings.development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PartSource.Data\PartSource.Data.csproj" />
|
||||
<ProjectReference Include="..\PartSource.Services\PartSource.Services.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
24
PartSource.Api/Program.cs
Normal file
24
PartSource.Api/Program.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace PartSource.Api
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
29
PartSource.Api/Properties/launchSettings.json
Normal file
29
PartSource.Api/Properties/launchSettings.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:31337",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchUrl": "api/values",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"PartSource.Api": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/values",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
64
PartSource.Api/Startup.cs
Normal file
64
PartSource.Api/Startup.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PartSource.Api.Formatters;
|
||||
using PartSource.Data;
|
||||
using PartSource.Services;
|
||||
|
||||
namespace PartSource.Api
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.OutputFormatters.Add(new LiquidTemplateOutputFormatter());
|
||||
});
|
||||
|
||||
services.AddTransient<PartService>();
|
||||
services.AddTransient<NexpartService>();
|
||||
services.AddTransient<SecurityService>();
|
||||
|
||||
services.AddCors(o => o.AddPolicy("Default", builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
}));
|
||||
|
||||
services.AddDbContext<PartSourceContext>(options =>
|
||||
options.UseSqlServer(Configuration.GetConnectionString("PartSourceDatabase"))
|
||||
);
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
{
|
||||
//if (env.IsDevelopment())
|
||||
//{
|
||||
// app.UseDeveloperExceptionPage();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// app.UseHsts();
|
||||
//}
|
||||
|
||||
app.UseCors("Default");
|
||||
|
||||
app.UseExceptionHandler("/Error");
|
||||
// app.UseHttpsRedirection();
|
||||
app.UseMvc();
|
||||
}
|
||||
}
|
||||
}
|
||||
6
PartSource.Api/appsettings.development.json
Normal file
6
PartSource.Api/appsettings.development.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
|
||||
"ConnectionStrings": {
|
||||
"PartSourceDatabase": "Server=(localdb)\\mssqllocaldb;Database=PartSource;Trusted_Connection=True;"
|
||||
}
|
||||
}
|
||||
21
PartSource.Api/appsettings.json
Normal file
21
PartSource.Api/appsettings.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"PartSourceDatabase": "Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Nexpart": {
|
||||
"ApiKey": "AFA5CC1431CD43DCA663C17BDAD850BB-C8F5BDF9A09C4464A66731CA4427CBB9",
|
||||
"ApiSecret": "7AB35766-0379-4DF0-9665-DAEE13822F43",
|
||||
"Url": "http://acespssint.nexpart.com:4001/partselect/1.0/services/PartSelectService.PartSelectHttpSoap11Endpoint/"
|
||||
},
|
||||
"Shopify": {
|
||||
"ApiKey": "9a533dad460321c6ce8f30bf5b8691ed",
|
||||
"ApiSecret": "dc9e28365d9858e544d57ac7af43fee7",
|
||||
"ShopDomain": "dev-partsource.myshopify.com"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user