.
This commit is contained in:
@@ -10,8 +10,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Api.Controllers
|
||||
{
|
||||
/// <remarks>
|
||||
/// This endpoint gets vehicle data from WHI's SEO data.
|
||||
/// </remarks>
|
||||
[Route("v2/[controller]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = "v2")]
|
||||
public class VehiclesController : BaseApiController
|
||||
{
|
||||
private readonly VehicleService _vehicleService;
|
||||
@@ -21,17 +25,30 @@ namespace PartSource.Api.Controllers
|
||||
_vehicleService = vehicleService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("")]
|
||||
public async Task<ActionResult> GetVehicles([FromQuery] Vehicle vehicleQuery)
|
||||
/// <summary>
|
||||
/// Get Vehicles
|
||||
/// </summary>
|
||||
/// <response code="200"><strong>OK:</strong> An array of vehicles matching the query.</response>
|
||||
/// <response code="204"><strong>No Content:</strong> The query executed successfully, but no vehicles were found.</response>
|
||||
[HttpGet("")]
|
||||
[ProducesResponseType(typeof(IList<VehicleDto>), 200)]
|
||||
[ProducesResponseType(204)]
|
||||
public async Task<ActionResult> GetVehicles([FromQuery] VehicleDto vehicleQuery)
|
||||
{
|
||||
IList<Vehicle> vehicles = await _vehicleService.GetVehicles(vehicleQuery);
|
||||
|
||||
return ApiResponse(vehicles);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
/// <summary>
|
||||
/// Get Vehicle by ID
|
||||
/// </summary>
|
||||
/// <param name="id">A WHI VehicleToEngineConfigId</param>
|
||||
/// <response code="200"><strong>OK:</strong> The vehicle with the provided VehicleToEngineConfigId.</response>
|
||||
/// <response code="404"><strong>Not Found:</strong> No vehicle was found matching the provided VehicleToEngineConfigId.</response>
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType(typeof(VehicleDto), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult> GetVehicleById(int id)
|
||||
{
|
||||
Vehicle vehicle = await _vehicleService.GetVehicleById(id);
|
||||
@@ -39,94 +56,162 @@ namespace PartSource.Api.Controllers
|
||||
return ApiResponse(vehicle);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes")]
|
||||
public async Task<ActionResult> GetMakes([FromQuery] VehicleMake vehicleMake)
|
||||
/// <summary>
|
||||
/// Get Makes
|
||||
/// </summary>
|
||||
/// <response code="200"><strong>OK:</strong> An array of makes matching the query.</response>
|
||||
/// <response code="204"><strong>No Content:</strong> The query executed successfully, but no makes were found.</response>
|
||||
[HttpGet("makes")]
|
||||
[ProducesResponseType(typeof(IList<MakeDto>), 200)]
|
||||
[ProducesResponseType(204)]
|
||||
public async Task<ActionResult> GetMakes([FromQuery] VehicleDto vehicleQuery)
|
||||
{
|
||||
IList<VehicleMake> makes = await _vehicleService.GetMakes(vehicleMake);
|
||||
IList<MakeDto> makes = await _vehicleService.GetMakes(vehicleQuery);
|
||||
|
||||
return ApiResponse(makes);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("makes/{id}")]
|
||||
/// <summary>
|
||||
/// Get Make by ID
|
||||
/// </summary>
|
||||
/// <param name="id">A WHI MakeId</param>
|
||||
/// <response code="200"><strong>OK:</strong> The make with the provided MakeId.</response>
|
||||
/// <response code="404"><strong>Not Found:</strong> No make was found matching the provided MakeId.</response>
|
||||
[HttpGet("makes/{id}")]
|
||||
[ProducesResponseType(typeof(MakeDto), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult> GetMakeById(int id)
|
||||
{
|
||||
VehicleMake make = await _vehicleService.GetMakeById(id);
|
||||
MakeDto make = await _vehicleService.GetMakeById(id);
|
||||
|
||||
return ApiResponse(make);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("models")]
|
||||
public async Task<ActionResult> GetModels([FromQuery] VehicleModel vehicleModel)
|
||||
/// <summary>
|
||||
/// Get Models
|
||||
/// </summary>
|
||||
/// <response code="200"><strong>OK:</strong> An array of models matching the query.</response>
|
||||
/// <response code="204"><strong>No Content:</strong> The query executed successfully, but no models were found.</response>
|
||||
[HttpGet("models")]
|
||||
[ProducesResponseType(typeof(IList<ModelDto>), 200)]
|
||||
[ProducesResponseType(204)]
|
||||
public async Task<ActionResult> GetModels([FromQuery] VehicleDto vehicleQuery)
|
||||
{
|
||||
IList<VehicleModel> models = await _vehicleService.GetModels(vehicleModel);
|
||||
IList<ModelDto> models = await _vehicleService.GetModels(vehicleQuery);
|
||||
|
||||
return ApiResponse(models);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("models/{id}")]
|
||||
/// <summary>
|
||||
/// Get Model by ID
|
||||
/// </summary>
|
||||
/// <param name="id">A WHI ModelId</param>
|
||||
/// <response code="200"><strong>OK:</strong> The model with the provided ModelId.</response>
|
||||
/// <response code="404"><strong>Not Found:</strong> No model was found matching the provided ModelId.</response>
|
||||
[HttpGet("models/{id}")]
|
||||
[ProducesResponseType(typeof(ModelDto), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult> GetModelById(int id)
|
||||
{
|
||||
VehicleModel model = await _vehicleService.GetModelById(id);
|
||||
ModelDto model = await _vehicleService.GetModelById(id);
|
||||
|
||||
return ApiResponse(model);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("basevehicles")]
|
||||
public async Task<ActionResult> GetBaseVehicles([FromQuery] BaseVehicle baseVehicle)
|
||||
/// <summary>
|
||||
/// Get Submodels
|
||||
/// </summary>
|
||||
/// /// <remarks><em>Note: Submodels can be shared between models. Do not assume a submodel is unique to a given model.</em></remarks>
|
||||
/// <response code="200"><strong>OK:</strong> An array of submodels matching the query.</response>
|
||||
/// <response code="204"><strong>No Content:</strong> The query executed successfully, but no submodels were found.</response>
|
||||
[HttpGet("submodels")]
|
||||
[ProducesResponseType(typeof(IList<SubmodelDto>), 200)]
|
||||
[ProducesResponseType(204)]
|
||||
public async Task<ActionResult> GetSubmodels([FromQuery] VehicleDto vehicleQuery)
|
||||
{
|
||||
IList<BaseVehicle> baseVehicles = await _vehicleService.GetBaseVehicles(baseVehicle);
|
||||
|
||||
return ApiResponse(baseVehicles);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("basevehicles/{id}")]
|
||||
public async Task<ActionResult> GetBaseVehicleById(int id)
|
||||
{
|
||||
BaseVehicle baseVehicle = await _vehicleService.GetBaseVehicleById(id);
|
||||
|
||||
return ApiResponse(baseVehicle);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("engines")]
|
||||
public async Task<ActionResult> GetEngines([FromQuery] Engine engine)
|
||||
{
|
||||
IList<Engine> engines = await _vehicleService.GetEngines(engine);
|
||||
|
||||
return ApiResponse(engines);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("engines/{id}")]
|
||||
public async Task<ActionResult> GetEngineById(int id)
|
||||
{
|
||||
EngineDto engine = await _vehicleService.GetEngineById(id);
|
||||
|
||||
return ApiResponse(engine);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("submodels")]
|
||||
public async Task<ActionResult> GetSubmodels([FromQuery] Submodel submodelQuery)
|
||||
{
|
||||
IList<Submodel> submodels = await _vehicleService.GetSubmodels(submodelQuery);
|
||||
IList<SubmodelDto> submodels = await _vehicleService.GetSubmodels(vehicleQuery);
|
||||
|
||||
return ApiResponse(submodels);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("submodels/{id}")]
|
||||
/// <summary>
|
||||
/// Get Submodel by ID
|
||||
/// </summary>
|
||||
/// <remarks><em>Note: Submodels can be shared between models. Do not assume a submodel is unique to a given model.</em></remarks>
|
||||
/// <param name="id">A WHI SubmodelId</param>
|
||||
/// <response code="200"><strong>OK:</strong> The submodel with the provided SubmodelId.</response>
|
||||
/// <response code="404"><strong>Not Found:</strong> No submodel was found matching the provided SubmodelId.</response>
|
||||
[HttpGet("submodels/{id}")]
|
||||
[ProducesResponseType(typeof(SubmodelDto), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult> GetSubmodels(int id)
|
||||
{
|
||||
SubmodelDto submodel = await _vehicleService.GetSubmodelById(id);
|
||||
|
||||
return ApiResponse(submodel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Base Vehicles
|
||||
/// </summary>
|
||||
/// <response code="200"><strong>OK:</strong> An array of base vehicles matching the query.</response>
|
||||
/// <response code="204"><strong>No Content:</strong> The query executed successfully, but no base vehicles were found.</response>
|
||||
[HttpGet("basevehicles")]
|
||||
[ProducesResponseType(typeof(IList<BaseVehicleDto>), 200)]
|
||||
[ProducesResponseType(204)]
|
||||
|
||||
public async Task<ActionResult> GetBaseVehicles([FromQuery] VehicleDto vehicleQuery)
|
||||
{
|
||||
IList<BaseVehicleDto> baseVehicles = await _vehicleService.GetBaseVehicles(vehicleQuery);
|
||||
|
||||
return ApiResponse(baseVehicles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Base Vehicle by ID
|
||||
/// </summary>
|
||||
/// <param name="id">A WHI BaseVehicleId</param>
|
||||
/// <response code="200"><strong>OK:</strong> The base vehicle with the provided BaseVehicleId.</response>
|
||||
/// <response code="404"><strong>Not Found:</strong> No base vehicle was found matching the provided BaseVehicleId.</response>
|
||||
[HttpGet("basevehicles/{id}")]
|
||||
[ProducesResponseType(typeof(BaseVehicleDto), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult> GetBaseVehicleById(int id)
|
||||
{
|
||||
BaseVehicleDto baseVehicle = await _vehicleService.GetBaseVehicleById(id);
|
||||
|
||||
return ApiResponse(baseVehicle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Engines
|
||||
/// </summary>
|
||||
/// <response code="200"><strong>OK:</strong> An array of engines matching the query.</response>
|
||||
/// <response code="204"><strong>No Content:</strong> The query executed successfully, but no engines were found.</response>
|
||||
[HttpGet("engines")]
|
||||
[ProducesResponseType(typeof(IList<EngineDto>), 200)]
|
||||
[ProducesResponseType(204)]
|
||||
public async Task<ActionResult> GetEngines([FromQuery] VehicleDto vehicleQuery)
|
||||
{
|
||||
IList<EngineDto> engines = await _vehicleService.GetEngines(vehicleQuery);
|
||||
|
||||
return ApiResponse(engines);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Engine by ID
|
||||
/// </summary>
|
||||
/// <param name="id">A WHI EngineConfigId</param>
|
||||
/// <response code="200"><strong>OK:</strong> The engine with the provided EngineConfigId.</response>
|
||||
/// <response code="404"><strong>Not Found:</strong> No engine was found matching the provided EngineConfigId.</response>
|
||||
[HttpGet("engines/{id}")]
|
||||
[ProducesResponseType(typeof(EngineDto), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult> GetEngineById(int id)
|
||||
{
|
||||
EngineDto engine = await _vehicleService.GetEngineById(id);
|
||||
|
||||
return ApiResponse(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user