57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using CandyHouseContracts.AdapterContracts;
|
|
using CandyHouseContracts.BindingModels;
|
|
|
|
namespace CandyHouseWebApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class IngredientsController(IIngredientAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly IIngredientAdapter _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] IngredientBindingModel model)
|
|
{
|
|
return _adapter.RegisterIngredient(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] IngredientBindingModel model)
|
|
{
|
|
return _adapter.ChangeIngredientInfo(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Delete(string id)
|
|
{
|
|
return _adapter.RemoveIngredient(id).GetResponse(Request, Response);
|
|
}
|
|
} |