State of OMG-LEGION prior to merge
This commit is contained in:
@@ -5,91 +5,128 @@ using PartSource.Data.Models;
|
||||
using PartSource.Data.Nexpart;
|
||||
using PartSource.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Part = PartSource.Data.Models.Part;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[Route("v2/[controller]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = "v1")]
|
||||
public class PartsController : BaseNexpartController
|
||||
{
|
||||
private readonly NexpartService _nexpartService;
|
||||
private readonly PartService _partService;
|
||||
private readonly VehicleService _vehicleService;
|
||||
|
||||
public PartsController(NexpartService nexpartService, PartService partService)
|
||||
public PartsController(NexpartService nexpartService, PartService partService, VehicleService vehicleService)
|
||||
{
|
||||
this._nexpartService = nexpartService;
|
||||
_nexpartService = nexpartService;
|
||||
_partService = partService;
|
||||
_vehicleService = vehicleService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("PartNumber/{partNumber}/LineCode/{lineCode}")]
|
||||
public ActionResult GetPart(string partNumber, string lineCode)
|
||||
[Route("positions")]
|
||||
public async Task<ActionResult> GetPositions([FromQuery] string sku, [FromQuery] int vehicleId)
|
||||
{
|
||||
new SmartPageDataSearch().Items = new Item[1]
|
||||
{
|
||||
new Item()
|
||||
{
|
||||
PartNumber = partNumber.ToUpperInvariant(),
|
||||
MfrCode = lineCode.ToUpperInvariant()
|
||||
}
|
||||
};
|
||||
return (ActionResult)this.Ok();
|
||||
}
|
||||
Part part = await _partService.GetPartBySku(sku);
|
||||
Vehicle vehicle = await _vehicleService.GetVehicleById(vehicleId);
|
||||
|
||||
[HttpGet]
|
||||
[Route("search/basevehicleid/{baseVehicleId}")]
|
||||
public async Task<ActionResult> Search(int baseVehicleId, [FromQuery] string query)
|
||||
{
|
||||
PartsController partsController = this;
|
||||
PartTypeSearch requestContent = new PartTypeSearch()
|
||||
if (part == null)
|
||||
{
|
||||
SearchString = query,
|
||||
SearchType = "ALL",
|
||||
SearchOptions = "PARTIAL_MATCH",
|
||||
VehicleIdentifier = new VehicleIdentifier()
|
||||
return BadRequest(new
|
||||
{
|
||||
BaseVehicleId = baseVehicleId
|
||||
}
|
||||
};
|
||||
|
||||
PartTypeSearchResponse response = await _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();
|
||||
Message = $"No part data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.",
|
||||
Reason = $"{nameof(_partService.GetPartBySku)} returned null"
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new { Data = fitments });
|
||||
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();
|
||||
|
||||
SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch
|
||||
{
|
||||
Items = items
|
||||
};
|
||||
|
||||
SmartPageDataSearchResponse smartPageResponse = await _nexpartService.SendRequest<SmartPageDataSearch, SmartPageDataSearchResponse>(smartPageDataSearch);
|
||||
if (smartPageResponse.ResponseBody?.Item == null)
|
||||
{
|
||||
return NotFound(new
|
||||
{
|
||||
Message = $"No WHI data is available for SKU {sku}",
|
||||
Reason = $"{nameof(SmartPageDataSearch)} returned null"
|
||||
});
|
||||
}
|
||||
|
||||
PartType[] partTypes = smartPageResponse.ResponseBody.Item.Select(i => new PartType
|
||||
{
|
||||
Id = i.Part.PartType.Id
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
ApplicationSearch applicationSearch = new ApplicationSearch
|
||||
{
|
||||
VehicleIdentifier = new VehicleIdentifier
|
||||
{
|
||||
BaseVehicleId = vehicle.BaseVehicleId
|
||||
},
|
||||
MfrCode = mappings.Select(m => m.WhiCode).ToArray(),
|
||||
PartType = new[] { new PartType { Id = smartPageResponse.ResponseBody.Item[0].Part.PartType.Id } },
|
||||
Criterion = new[]
|
||||
{
|
||||
new Criterion
|
||||
{
|
||||
Attribute = "REGION",
|
||||
Id = 2
|
||||
}
|
||||
},
|
||||
GroupBy = "PARTTYPE"
|
||||
};
|
||||
|
||||
ApplicationSearchResponse response = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
|
||||
|
||||
if (response.ResponseBody == null)
|
||||
{
|
||||
return NotFound(new
|
||||
{
|
||||
Message = $"No WHI data is available for SKU {sku}",
|
||||
Reason = $"{nameof(ApplicationSearch)} returned null"
|
||||
});
|
||||
}
|
||||
|
||||
IList<string> positions = new List<string>();
|
||||
foreach (App app in response.ResponseBody?.App)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(app.Position) && app.Part == part.PartNumber)
|
||||
{
|
||||
positions.Add(app.Position);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
VehicleId = vehicleId,
|
||||
Sku = sku,
|
||||
Positions = positions.Distinct()
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
63
PartSource.Api/Controllers/WipersController.cs
Normal file
63
PartSource.Api/Controllers/WipersController.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
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;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = "v1")]
|
||||
public class WipersController : BaseNexpartController
|
||||
{
|
||||
private readonly NexpartService _nexpartService;
|
||||
|
||||
public WipersController(NexpartService nexpartService)
|
||||
{
|
||||
_nexpartService = nexpartService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{baseVehicleId}")]
|
||||
public async Task<ActionResult> GetWipersForVehicle(int baseVehicleId)
|
||||
{
|
||||
ApplicationSearch applicationSearch = new ApplicationSearch
|
||||
{
|
||||
VehicleIdentifier = new VehicleIdentifier
|
||||
{
|
||||
BaseVehicleId = baseVehicleId
|
||||
},
|
||||
MfrCode = new[] { "BOS", "TRI" },
|
||||
PartType = new[]
|
||||
{
|
||||
new PartType { Id = 8852 }
|
||||
},
|
||||
Criterion = new[]
|
||||
{
|
||||
new Criterion
|
||||
{
|
||||
Attribute = "REGION",
|
||||
Id = 2
|
||||
}
|
||||
},
|
||||
GroupBy = "PARTTYPE"
|
||||
};
|
||||
|
||||
ApplicationSearchResponse response = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
|
||||
|
||||
if (response.ResponseBody != null)
|
||||
{
|
||||
return NexpartResponse<ApplicationSearchResponse, Apps>(response);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,14 +30,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.15" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.5" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Ratermania.Shopify" Version="1.3.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="5.5.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="6.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -67,9 +67,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.
|
||||
@@ -86,12 +86,12 @@ namespace PartSource.Api
|
||||
|
||||
app.UseCors("Default");
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseReDoc(c =>
|
||||
{
|
||||
c.SpecUrl = "/swagger/v2/swagger.json";
|
||||
c.ExpandResponses(string.Empty);
|
||||
});
|
||||
//app.UseSwagger();
|
||||
//app.UseReDoc(c =>
|
||||
//{
|
||||
// c.SpecUrl = "/swagger/v2/swagger.json";
|
||||
// c.ExpandResponses(string.Empty);
|
||||
//});
|
||||
|
||||
// app.UseExceptionHandler("/Error");
|
||||
// app.UseHttpsRedirection();
|
||||
|
||||
@@ -1,7 +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": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
|
||||
//"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user