using Managing.Application.Abstractions.Services;
using Managing.Domain.Workers;
using Microsoft.AspNetCore.Mvc;
using static Managing.Common.Enums;

namespace Managing.Api.Workers.Controllers;

[ApiController]
[Route("[controller]")]
[Produces("application/json")]
public class WorkerController : ControllerBase
{
    private readonly IWorkerService _workerService;

    public WorkerController(IWorkerService workerService)
    {
        _workerService = workerService;
    }

    [HttpGet]
    public async Task<ActionResult<List<Worker>>> GetWorkers()
    {
        var workers = await _workerService.GetWorkers();
        return Ok(workers.ToList());
    }

    [HttpPatch]
    public async Task<ActionResult> ToggleWorker(WorkerType workerType)
    {
        return Ok(await _workerService.ToggleWorker(workerType));
    }
}