.
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
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\.editorconfig" Link=".editorconfig" />
|
||||
<None Include="appsettings.development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
@@ -52,13 +52,12 @@ namespace PartSource.Api
|
||||
services.AddAutoMapper(typeof(PartSourceProfile));
|
||||
|
||||
services.AddTransient<PartService>();
|
||||
services.AddTransient<FitmentService>();
|
||||
services.AddTransient<NexpartService>();
|
||||
services.AddTransient<SecurityService>();
|
||||
services.AddTransient<VehicleService>();
|
||||
services.AddTransient<ShopifyChangelogService>();
|
||||
|
||||
services.AddTransient<FitmentContext>();
|
||||
|
||||
services.AddCors(o => o.AddPolicy("Default", builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
@@ -69,9 +68,9 @@ namespace PartSource.Api
|
||||
services.AddDbContext<PartSourceContext>(options =>
|
||||
options.UseSqlServer(Configuration.GetConnectionString("PartSourceDatabase"))
|
||||
);
|
||||
//services.AddDbContext<FitmentContext>(options =>
|
||||
// options.UseSqlServer(Configuration.GetConnectionString("FitmentDatabase"))
|
||||
//);
|
||||
services.AddDbContext<FitmentContext>(options =>
|
||||
options.UseSqlServer(Configuration.GetConnectionString("FitmentDatabase"))
|
||||
);
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"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;",
|
||||
"FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=automation;Password=)6L)XP%m(x-UU#M;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300"
|
||||
//"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
|
||||
},
|
||||
"Logging": {
|
||||
|
||||
Reference in New Issue
Block a user