using MagicCarpetContracts.AdapterContracts; using MagicCarpetContracts.BindingModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace MagicCarpetWebApi.Controllers; [Authorize] [Route("api/[controller]/[action]")] [ApiController] [Produces("application/json")] public class EmployeesController(IEmployeeAdapter adapter) : ControllerBase { private readonly IEmployeeAdapter _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] EmployeeBindingModel model) { return _adapter.RegisterEmployee(model).GetResponse(Request, Response); } [HttpPut] public IActionResult ChangeInfo([FromBody] EmployeeBindingModel model) { return _adapter.ChangeEmployeeInfo(model).GetResponse(Request, Response); } [HttpDelete("{id}")] public IActionResult Delete(string id) { return _adapter.RemoveEmployee(id).GetResponse(Request, Response); } }