45 lines
1.1 KiB
C#
45 lines
1.1 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 BuyersController(IBuyerAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly IBuyerAdapter _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] BuyerBindingModel model)
|
|
{
|
|
return _adapter.RegisterBuyer(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] BuyerBindingModel model)
|
|
{
|
|
return _adapter.ChangeBuyerInfo(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Delete(string id)
|
|
{
|
|
return _adapter.RemoveBuyer(id).GetResponse(Request, Response);
|
|
}
|
|
} |