WIP
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]
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Ratermania.Shopify" Version="6.16.11" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="6.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace PartSource.Api
|
||||
|
||||
services.AddAutoMapper(typeof(PartSourceProfile));
|
||||
|
||||
services.AddTransient<FitmentService>();
|
||||
services.AddTransient<PartService>();
|
||||
services.AddTransient<NexpartService>();
|
||||
services.AddTransient<SecurityService>();
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
<PackageReference Include="Ratermania.Automation" Version="6.16.9" />
|
||||
<PackageReference Include="Ratermania.Automation.Common" Version="6.16.9" />
|
||||
<PackageReference Include="Ratermania.JwtSpot" Version="6.16.9" />
|
||||
<PackageReference Include="Ratermania.Shopify" Version="6.16.11" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ratermania\Packages\Shopify\Shopify.csproj" />
|
||||
<ProjectReference Include="..\PartSource.Data\PartSource.Data.csproj" />
|
||||
<ProjectReference Include="..\PartSource.Services\PartSource.Services.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -122,38 +122,5 @@ namespace PartSource.Automation.Services
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
|
||||
public IList<VehicleFitmentDto> GetVehicleFitmentForPart(string partNumber, string lineCode, int maxVehicles = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty);
|
||||
|
||||
IQueryable<string> whiCodes = _fitmentContext.DcfMappings
|
||||
.Where(d => d.LineCode == lineCode)
|
||||
.Select(d => d.WhiCode);
|
||||
|
||||
IQueryable<VehicleFitmentDto> vehicles = _fitmentContext.Fitments
|
||||
.Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode))
|
||||
.Join(_fitmentContext.Vehicles,
|
||||
f => new { f.BaseVehicleId, f.EngineConfigId },
|
||||
v => new { v.BaseVehicleId, v.EngineConfigId },
|
||||
(f, v) => new VehicleFitmentDto
|
||||
{
|
||||
Fitment = f,
|
||||
Vehicle = v
|
||||
})
|
||||
.Distinct();
|
||||
|
||||
if (maxVehicles > 0)
|
||||
{
|
||||
vehicles = vehicles.Take(maxVehicles);
|
||||
}
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@ using System.Text;
|
||||
|
||||
namespace PartSource.Data.Dtos
|
||||
{
|
||||
public class VehicleFitmentDto
|
||||
public class VehicleFitmentDto : VehicleFitment
|
||||
{
|
||||
public Fitment Fitment { get; set; }
|
||||
|
||||
public Vehicle Vehicle { get; set; }
|
||||
public IList<string> SubmodelNames { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PartSource.Data.Contexts;
|
||||
using PartSource.Data.Dtos;
|
||||
using PartSource.Data.Models;
|
||||
@@ -155,38 +156,5 @@ namespace PartSource.Services
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
|
||||
public IList<VehicleFitmentDto> GetVehicleFitmentForPart(string partNumber, string lineCode, int maxVehicles = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty);
|
||||
|
||||
IQueryable<string> whiCodes = _fitmentContext.DcfMappings
|
||||
.Where(d => d.LineCode == lineCode)
|
||||
.Select(d => d.WhiCode);
|
||||
|
||||
IQueryable<VehicleFitmentDto> vehicles = _fitmentContext.Fitments
|
||||
.Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode))
|
||||
.Join(_fitmentContext.Vehicles,
|
||||
f => new { f.BaseVehicleId, f.EngineConfigId },
|
||||
v => new { v.BaseVehicleId, v.EngineConfigId },
|
||||
(f, v) => new VehicleFitmentDto
|
||||
{
|
||||
Fitment = f,
|
||||
Vehicle = v
|
||||
})
|
||||
.Distinct();
|
||||
|
||||
if (maxVehicles > 0)
|
||||
{
|
||||
vehicles = vehicles.Take(maxVehicles);
|
||||
}
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="11.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Ratermania.Shopify" Version="6.16.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ratermania\Packages\Shopify\Shopify.csproj" />
|
||||
<ProjectReference Include="..\PartSource.Data\PartSource.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PartSource.Services", "Part
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PartSource.Automation", "PartSource.Automation\PartSource.Automation.csproj", "{C85D675B-A76C-4F9C-9C57-1E063211C946}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shopify", "..\ratermania\Packages\Shopify\Shopify.csproj", "{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Also Debug|Any CPU = Also Debug|Any CPU
|
||||
@@ -98,24 +96,6 @@ Global
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user