63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using CatHasPawsContratcs.AdapterContracts;
|
|
using CatHasPawsContratcs.BindingModels;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CatHasPawsWebApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class WorkersController(IWorkerAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly IWorkerAdapter _adapter = adapter;
|
|
|
|
[HttpGet]
|
|
public IActionResult GetRecords(bool includeDeleted = false)
|
|
{
|
|
return _adapter.GetList(includeDeleted).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetPostRecords(string id, bool includeDeleted = false)
|
|
{
|
|
return _adapter.GetPostList(id, includeDeleted).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetBirthDateRecords(DateTime fromDate, DateTime toDate, bool includeDeleted = false)
|
|
{
|
|
return _adapter.GetListByBirthDate(fromDate, toDate, includeDeleted).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetEmploymentRecords(DateTime fromDate, DateTime toDate, bool includeDeleted = false)
|
|
{
|
|
return _adapter.GetListByEmploymentDate(fromDate, toDate, includeDeleted).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("{data}")]
|
|
public IActionResult GetRecord(string data)
|
|
{
|
|
return _adapter.GetElement(data).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Register([FromBody] WorkerBindingModel model)
|
|
{
|
|
return _adapter.RegisterWorker(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPut]
|
|
public IActionResult ChangeInfo([FromBody] WorkerBindingModel model)
|
|
{
|
|
return _adapter.ChangeWorkerInfo(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Delete(string id)
|
|
{
|
|
return _adapter.RemoveWorker(id).GetResponse(Request, Response);
|
|
}
|
|
} |