Whatever this is
This commit is contained in:
@@ -13,11 +13,11 @@ namespace PartSource.Services
|
||||
{
|
||||
public class FitmentService
|
||||
{
|
||||
private readonly FitmentContext _fitmentContext;
|
||||
private readonly FitmentContext _fitmentContext;
|
||||
|
||||
public FitmentService(FitmentContext fitmentContext)
|
||||
public FitmentService(FitmentContext fitmentContext)
|
||||
{
|
||||
_fitmentContext = fitmentContext;
|
||||
_fitmentContext = fitmentContext;
|
||||
}
|
||||
|
||||
public async Task<VehicleFitmentDto> GetFitmentNotes(string sku, int vehicleId)
|
||||
@@ -36,120 +36,115 @@ namespace PartSource.Services
|
||||
BaseVehicleId = vf.BaseVehicleId,
|
||||
EngineConfigId = vf.EngineConfigId,
|
||||
VehicleToEngineConfigId = vf.VehicleToEngineConfigId,
|
||||
SubmodelName = vf.SubmodelName
|
||||
SubmodelName = vf.SubmodelName
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (vehicleFitment == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return vehicleFitment;
|
||||
}
|
||||
|
||||
public IList<string> GetYmmFitment(IList<Vehicle> vehicles)
|
||||
{
|
||||
if (vehicles.Count == 0)
|
||||
{
|
||||
return new string[0];
|
||||
}
|
||||
{
|
||||
if (vehicles.Count == 0)
|
||||
{
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
IList<string> fitmentTags = new List<string>();
|
||||
IList<string> fitmentTags = new List<string>();
|
||||
|
||||
IList<string> makeModels = vehicles.OrderBy(v => v.MakeName).ThenBy(v => v.ModelName).Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList();
|
||||
IList<string> makeModels = vehicles.OrderBy(v => v.MakeName).ThenBy(v => v.ModelName).Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList();
|
||||
|
||||
foreach (string makeModel in makeModels)
|
||||
{
|
||||
string make = makeModel.Split(',')[0];
|
||||
string model = makeModel.Split(',')[1];
|
||||
foreach (string makeModel in makeModels)
|
||||
{
|
||||
string make = makeModel.Split(',')[0];
|
||||
string model = makeModel.Split(',')[1];
|
||||
|
||||
List<string> years = vehicles
|
||||
.Where(v => v.MakeName == make && v.ModelName == model)
|
||||
.OrderBy(v => v.Year)
|
||||
.Select(v => v.Year.ToString().Trim())
|
||||
.Distinct()
|
||||
.ToList();
|
||||
List<string> years = vehicles
|
||||
.Where(v => v.MakeName == make && v.ModelName == model)
|
||||
.OrderBy(v => v.Year)
|
||||
.Select(v => v.Year.ToString().Trim())
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
string tag = $"{string.Join('-', years)} {make.Trim()} {model.Trim()}";
|
||||
string tag = $"{string.Join('-', years)} {make.Trim()} {model.Trim()}";
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(tag);
|
||||
System.Diagnostics.Debug.WriteLine(tag);
|
||||
|
||||
fitmentTags.Add(tag);
|
||||
}
|
||||
fitmentTags.Add(tag);
|
||||
}
|
||||
|
||||
return fitmentTags;
|
||||
}
|
||||
return fitmentTags;
|
||||
}
|
||||
|
||||
public IList<string> GetYmmFitmentRange(IList<Vehicle> vehicles)
|
||||
{
|
||||
if (vehicles.Count == 0)
|
||||
{
|
||||
return new string[0];
|
||||
}
|
||||
public IList<string> GetYmmFitmentRange(IList<Vehicle> vehicles)
|
||||
{
|
||||
if (vehicles.Count == 0)
|
||||
{
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
IList<string> fitmentTags = new List<string>();
|
||||
IList<string> fitmentTags = new List<string>();
|
||||
|
||||
IList<string> makeModels = vehicles.Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList();
|
||||
IList<string> makeModels = vehicles.Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList();
|
||||
|
||||
foreach (string makeModel in makeModels)
|
||||
{
|
||||
string make = makeModel.Split(',')[0];
|
||||
string model = makeModel.Split(',')[1];
|
||||
foreach (string makeModel in makeModels)
|
||||
{
|
||||
string make = makeModel.Split(',')[0];
|
||||
string model = makeModel.Split(',')[1];
|
||||
|
||||
int minYear = vehicles
|
||||
.Where(v => v.MakeName == make && v.ModelName == model)
|
||||
.Min(v => v.Year);
|
||||
int minYear = vehicles
|
||||
.Where(v => v.MakeName == make && v.ModelName == model)
|
||||
.Min(v => v.Year);
|
||||
|
||||
int maxYear = vehicles
|
||||
.Where(v => v.MakeName == make && v.ModelName == model)
|
||||
.Max(v => v.Year);
|
||||
int maxYear = vehicles
|
||||
.Where(v => v.MakeName == make && v.ModelName == model)
|
||||
.Max(v => v.Year);
|
||||
|
||||
string tag = minYear == maxYear
|
||||
? $"{minYear} {make.Trim()} {model.Trim()}"
|
||||
: $"{minYear}-{maxYear} {make.Trim()} {model.Trim()}";
|
||||
string tag = minYear == maxYear
|
||||
? $"{minYear} {make.Trim()} {model.Trim()}"
|
||||
: $"{minYear}-{maxYear} {make.Trim()} {model.Trim()}";
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(tag);
|
||||
System.Diagnostics.Debug.WriteLine(tag);
|
||||
|
||||
fitmentTags.Add(tag);
|
||||
}
|
||||
fitmentTags.Add(tag);
|
||||
}
|
||||
|
||||
return fitmentTags;
|
||||
}
|
||||
return fitmentTags;
|
||||
}
|
||||
|
||||
public IList<int> GetVehicleIdFitment(IList<Vehicle> vehicles)
|
||||
{
|
||||
return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToList();
|
||||
}
|
||||
public IList<int> GetVehicleIdFitment(IList<Vehicle> vehicles)
|
||||
{
|
||||
return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToList();
|
||||
}
|
||||
|
||||
public IList<Vehicle> GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public IList<Vehicle> GetVehiclesForPart(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);
|
||||
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<string> whiCodes = _fitmentContext.DcfMappings
|
||||
.Where(d => d.LineCode == lineCode)
|
||||
.Select(d => d.WhiCode);
|
||||
|
||||
IQueryable<Vehicle> 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) => v)
|
||||
.Distinct()
|
||||
.OrderByDescending(x => x.Year);
|
||||
IQueryable<Vehicle> 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) => v)
|
||||
.Distinct()
|
||||
.OrderByDescending(x => x.Year);
|
||||
|
||||
if (maxVehicles > 0)
|
||||
{
|
||||
vehicles = vehicles.Take(maxVehicles);
|
||||
}
|
||||
if (maxVehicles > 0)
|
||||
{
|
||||
vehicles = vehicles.Take(maxVehicles);
|
||||
}
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
}
|
||||
return vehicles.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,17 +25,20 @@ namespace PartSource.Services
|
||||
U content;
|
||||
|
||||
string x = textWriter.ToString();
|
||||
|
||||
using (HttpClient client = new HttpClient())
|
||||
System.Diagnostics.Debug.WriteLine(x);
|
||||
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "QjM4ODAyMzM3QjQxNEM2QTk4M0RFMjM0Mjk4Rjk4M0UtOUIzNUUxNzNBQUYxNEE2QjhCQjI2RjZDOUY2ODk1NDU6MkMzOUVCOTYtRDBBRS00QkVBLTlCMzItMUYyNTA5MDJGQTE0");
|
||||
try
|
||||
{
|
||||
//HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["NexpartUrl"], (HttpContent)new StringContent(sb.ToString(), Encoding.UTF8, "text/xml"));
|
||||
HttpResponseMessage response = await client.PostAsync("https://acespssprod.nexpart.com:4085/partselect/2.0/services/PartSelectService.PartSelectHttpSoap11Endpoint", new StringContent(textWriter.ToString(), Encoding.UTF8, "text/xml"));
|
||||
HttpResponseMessage response = await client.PostAsync("http://acespssprod.nexpart.com:8085/partselect/2.0/services/PartSelectService.PartSelectHttpSoap11Endpoint", new StringContent(textWriter.ToString(), Encoding.UTF8, "text/xml"));
|
||||
Stream result = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
string str = await response.Content.ReadAsStringAsync();
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(str);
|
||||
|
||||
content = (U)((Envelope)serializer.Deserialize(result)).Body.Content;
|
||||
;
|
||||
}
|
||||
@@ -44,6 +47,7 @@ namespace PartSource.Services
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,26 +12,28 @@ namespace PartSource.Services
|
||||
{
|
||||
public class PartService
|
||||
{
|
||||
private readonly PartSourceContext _context;
|
||||
private readonly PartSourceContext _partSourceContext;
|
||||
private readonly FitmentContext _fitmentContext;
|
||||
|
||||
public PartService(PartSourceContext context)
|
||||
public PartService(PartSourceContext partSourceContext, FitmentContext fitmentContext)
|
||||
{
|
||||
_context = context;
|
||||
_partSourceContext = partSourceContext;
|
||||
_fitmentContext = fitmentContext;
|
||||
}
|
||||
|
||||
public async Task<PartsAvailability> GetInventory(int sku, int storeNumber)
|
||||
{
|
||||
return await _context.PartAvailabilities.FirstOrDefaultAsync(s => s.Store == storeNumber && s.SKU == sku);
|
||||
return await _partSourceContext.PartAvailabilities.FirstOrDefaultAsync(s => s.Store == storeNumber && s.SKU == sku);
|
||||
}
|
||||
|
||||
public async Task<Part> GetPartBySku(string sku)
|
||||
{
|
||||
return await _context.Parts.SingleOrDefaultAsync(p => p.Sku == sku);
|
||||
return await _fitmentContext.Parts.SingleOrDefaultAsync(p => p.Sku == sku);
|
||||
}
|
||||
|
||||
public async Task<IList<DcfMapping>> GetDcfMapping(string partsourceLineCode)
|
||||
{
|
||||
return await _context.DcfMappings
|
||||
return await _fitmentContext.DcfMappings
|
||||
.Where(dcf => dcf.LineCode == partsourceLineCode)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user