45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using CatHasPawsContratcs.AdapterContracts;
|
|
using CatHasPawsContratcs.BindingModels;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CatHasPawsWebApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class ManufacturersController(IManufacturerAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly IManufacturerAdapter _adapter = adapter;
|
|
|
|
[HttpGet]
|
|
public IActionResult GetAllRecords()
|
|
{
|
|
return _adapter.GetList().GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("{data}")]
|
|
public IActionResult GetRecord(string data)
|
|
{
|
|
return _adapter.GetElement(data).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Register([FromBody] ManufacturerBindingModel model)
|
|
{
|
|
return _adapter.RegisterManufacturer(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] ManufacturerBindingModel model)
|
|
{
|
|
return _adapter.ChangeManufacturerInfo(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Delete(string id)
|
|
{
|
|
return _adapter.RemoveManufacturer(id).GetResponse(Request, Response);
|
|
}
|
|
} |