using CatHasPawsContratcs.AdapterContracts; using CatHasPawsContratcs.BindingModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace CatHasPawsWebApi.Controllers; [Authorize] [Route("api/[controller]/[action]")] [ApiController] [Produces("application/json")] public class ProductsController(IProductAdapter adapter) : ControllerBase { private readonly IProductAdapter _adapter = adapter; [HttpGet] public IActionResult GetRecords(bool includeDeleted) { return _adapter.GetList(includeDeleted).GetResponse(Request, Response); } [HttpGet] public IActionResult GetManufacturerRecords(string id, bool includeDeleted) { return _adapter.GetManufacturerList(id, includeDeleted).GetResponse(Request, Response); } [HttpGet] public IActionResult GetHistory(string id) { return _adapter.GetHistory(id).GetResponse(Request, Response); } [HttpGet("{data}")] public IActionResult GetRecord(string data) { return _adapter.GetElement(data).GetResponse(Request, Response); } [HttpPost] public IActionResult Register([FromBody] ProductBindingModel model) { return _adapter.RegisterProduct(model).GetResponse(Request, Response); } [HttpPut] public IActionResult ChangeInfo([FromBody] ProductBindingModel model) { return _adapter.ChangeProductInfo(model).GetResponse(Request, Response); } [HttpDelete("{id}")] public IActionResult Delete(string id) { return _adapter.RemoveProduct(id).GetResponse(Request, Response); } }