59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SmallSoftwareContracts.AdapterContracts;
|
|
using SmallSoftwareContracts.BindingModels;
|
|
|
|
namespace SmallSoftwareWebApi.Controllers;
|
|
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
|
|
public class SoftwaresController(ISoftwareAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly ISoftwareAdapter _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] SoftwareBindingModel model)
|
|
{
|
|
return _adapter.RegisterSoftware(model).GetResponse(Request,
|
|
Response);
|
|
}
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] SoftwareBindingModel model)
|
|
{
|
|
return _adapter.ChangeSoftwareInfo(model).GetResponse(Request,
|
|
Response);
|
|
}
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Delete(string id)
|
|
{
|
|
return _adapter.RemoveSoftware(id).GetResponse(Request, Response);
|
|
}
|
|
}
|
|
|