Whatever this is
This commit is contained in:
@@ -4,6 +4,7 @@ using PartSource.Data.Dtos;
|
||||
using PartSource.Data.Models;
|
||||
using PartSource.Data.Nexpart;
|
||||
using PartSource.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -41,14 +42,27 @@ namespace PartSource.Api.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Item[] items = new[]
|
||||
try
|
||||
{
|
||||
new Item { PartNumber = vehicleFitment.PartNumber, MfrCode = vehicleFitment.LineCode }
|
||||
};
|
||||
string[] segments = vehicleFitment.NoteText.Split(']');
|
||||
vehicleFitment.PartDescription = segments[0].TrimStart('[');
|
||||
vehicleFitment.DriveTypes = GetDriveTypesFromNote(vehicleFitment.NoteText);
|
||||
vehicleFitment.Notes = segments[1].Split(';')
|
||||
.Select(n => n.Trim())
|
||||
.ToList();
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
throw new InvalidOperationException($"The note_text field provided by WHI for {vehicleFitment.LineCode} {vehicleFitment.PartNumber} was in an invalid format.");
|
||||
}
|
||||
|
||||
SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch
|
||||
{
|
||||
Items = items
|
||||
Items = new[]
|
||||
{
|
||||
new Item { PartNumber = vehicleFitment.PartNumber, MfrCode = vehicleFitment.LineCode }
|
||||
}
|
||||
};
|
||||
|
||||
SmartPageDataSearchResponse smartPageResponse = await _nexpartService.SendRequest<SmartPageDataSearch, SmartPageDataSearchResponse>(smartPageDataSearch);
|
||||
@@ -74,10 +88,8 @@ namespace PartSource.Api.Controllers
|
||||
};
|
||||
|
||||
ApplicationSearchResponse response = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
|
||||
if (response.ResponseBody != null)
|
||||
if (response.ResponseBody != null && response.ResponseBody is Questions)
|
||||
{
|
||||
vehicleFitment.DriveTypes = new List<string>();
|
||||
|
||||
Question driveTypeQuestion = ((Questions)response.ResponseBody).Question
|
||||
.Where(q => q.Attribute == "DRIVE_TYPE")
|
||||
.FirstOrDefault();
|
||||
@@ -124,7 +136,7 @@ namespace PartSource.Api.Controllers
|
||||
{
|
||||
return BadRequest(new
|
||||
{
|
||||
Message = $"No vehicle data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.",
|
||||
Message = $"No vehicle data is available for vehicle ID {vehicleId}. Confirm it is available in the database maintained by Sound Press.",
|
||||
Reason = $"{nameof(_vehicleService.GetVehicleById)} returned null"
|
||||
});
|
||||
}
|
||||
@@ -167,13 +179,13 @@ namespace PartSource.Api.Controllers
|
||||
MfrCode = mappings.Select(m => m.WhiCode).ToArray(),
|
||||
PartType = new[] { new PartType { Id = smartPageResponse.ResponseBody.Item[0].Part.PartType.Id } },
|
||||
Criterion = new[]
|
||||
{
|
||||
new Criterion
|
||||
{
|
||||
new Criterion
|
||||
{
|
||||
Attribute = "REGION",
|
||||
Id = 2
|
||||
}
|
||||
},
|
||||
Attribute = "REGION",
|
||||
Id = 2
|
||||
}
|
||||
},
|
||||
GroupBy = "PARTTYPE"
|
||||
};
|
||||
|
||||
@@ -205,5 +217,33 @@ namespace PartSource.Api.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
private IList<string> GetDriveTypesFromNote(string fitmentNote)
|
||||
{
|
||||
fitmentNote = fitmentNote.ToUpperInvariant();
|
||||
IList<string> driveTypes = new List<string>();
|
||||
|
||||
if (fitmentNote.Contains("FWD"))
|
||||
{
|
||||
driveTypes.Add("FWD");
|
||||
}
|
||||
|
||||
if (fitmentNote.Contains("RWD"))
|
||||
{
|
||||
driveTypes.Add("RWD");
|
||||
}
|
||||
|
||||
if (fitmentNote.Contains("AWD"))
|
||||
{
|
||||
driveTypes.Add("AWD");
|
||||
}
|
||||
|
||||
if (fitmentNote.Contains("4WD"))
|
||||
{
|
||||
driveTypes.Add("4WD");
|
||||
}
|
||||
|
||||
return driveTypes;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,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": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
|
||||
"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": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user