58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PimpMyRideContracts.AdapterContracts;
|
|
using PimpMyRideContracts.BindingModels;
|
|
|
|
namespace PimpMyRideWebApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class CarController(ICarAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly ICarAdapter _adapter = adapter;
|
|
|
|
[HttpGet]
|
|
public IActionResult GetAllRecords()
|
|
{
|
|
return _adapter.GetList().GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("getclientrecords")]
|
|
public IActionResult GetClientRecords(string id)
|
|
{
|
|
return _adapter.GetClientList(id).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("getmakerecords")]
|
|
public IActionResult GetMakeRecords(string make, string model)
|
|
{
|
|
return _adapter.GetMakeList(make, model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("{data}")]
|
|
public IActionResult GetRecord(string data)
|
|
{
|
|
return _adapter.GetElement(data).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Register([FromBody] CarBindingModel model)
|
|
{
|
|
return _adapter.RegisterCar(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] CarBindingModel model)
|
|
{
|
|
return _adapter.ChangeCarInfo(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Delete(string id)
|
|
{
|
|
return _adapter.RemoveCar(id).GetResponse(Request, Response);
|
|
}
|
|
}
|