forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using MagicCarpetContracts.AdapterContracts;
|
|
using MagicCarpetContracts.BindingModels;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace MagicCarpetWebApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class SuppliesController(ISuppliesAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly ISuppliesAdapter _adapter = adapter;
|
|
|
|
[HttpGet]
|
|
public IActionResult GetAll()
|
|
{
|
|
return _adapter.GetAllComponents().GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("{data}")]
|
|
public IActionResult GetComponentByData(string data)
|
|
{
|
|
return _adapter.GetComponentByData(data).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Register([FromBody] SuppliesBindingModel suppliesBindingModel)
|
|
{
|
|
return _adapter.InsertComponent(suppliesBindingModel).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] SuppliesBindingModel suppliesBindingModel)
|
|
{
|
|
return _adapter.UpdateComponent(suppliesBindingModel).GetResponse(Request, Response);
|
|
}
|
|
}
|