Files
Pibd-21_Semin_D.A._SmallSof…/SmallSoftwareProject/SmallSoftwareWebApi/Controllers/SoftwaresController.cs
2025-03-27 06:55:34 +04:00

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);
}
}