52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SmallSoftwareContracts.AdapterContracts;
|
|
using SmallSoftwareContracts.BindingModels;
|
|
|
|
namespace SmallSoftwareWebApi.Controllers;
|
|
[Authorize]
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class RequestsController(IRequestAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly IRequestAdapter _adapter = adapter;
|
|
[HttpGet]
|
|
public IActionResult GetRecords(DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetList(fromDate, toDate).GetResponse(Request, Response);
|
|
}
|
|
[HttpGet]
|
|
public IActionResult GetWorkerRecords(string id, DateTime fromDate,
|
|
DateTime toDate)
|
|
{
|
|
return _adapter.GetWorkerList(id, fromDate,
|
|
toDate).GetResponse(Request, Response);
|
|
}
|
|
[HttpGet]
|
|
|
|
[HttpGet]
|
|
public IActionResult GetSoftwareRecords(string id, DateTime fromDate,
|
|
DateTime toDate)
|
|
{
|
|
return _adapter.GetSoftwareList(id, fromDate,
|
|
toDate).GetResponse(Request, Response);
|
|
}
|
|
[HttpGet("{data}")]
|
|
public IActionResult GetRecord(string data)
|
|
{
|
|
return _adapter.GetElement(data).GetResponse(Request, Response);
|
|
}
|
|
[HttpPost]
|
|
public IActionResult Request_([FromBody] RequestBindingModel model)
|
|
{
|
|
return _adapter.MakeRequest(model).GetResponse(Request, Response);
|
|
}
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Cancel(string id)
|
|
{
|
|
return _adapter.CancelRequest(id).GetResponse(Request, Response);
|
|
}
|
|
|
|
}
|