33 lines
991 B
C#
33 lines
991 B
C#
using MagicCarpetContracts.AdapterContracts;
|
|
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 SalaryController(ISalaryAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly ISalaryAdapter _adapter = adapter;
|
|
|
|
[HttpGet]
|
|
public IActionResult GetRecords(DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetListByPeriod(fromDate, toDate).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetEmployeeRecords(string id, DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetListByPeriodByEmployee(fromDate, toDate, id).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Calculate(DateTime date)
|
|
{
|
|
return _adapter.CalculateSalary(date).GetResponse(Request, Response);
|
|
}
|
|
} |