using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RobotNet.RobotManager.Services.OpenACS;
using RobotNet.RobotShares.OpenACS;
using RobotNet.Shares;

namespace RobotNet.RobotManager.Controllers;

[Route("api/[controller]")]
[ApiController]
[Authorize]
public class TrafficACSRequestController(TrafficACS TrafficACS, Services.RobotManager RobotManager) : ControllerBase
{
    [HttpPost]
    public async Task<MessageResult<bool>> UpdateTrafficSetting([FromBody] TrafficACSRequestModel model)
        => model.Type switch
        {
            TrafficRequestType.IN => await TrafficACS.RequestIn(model.RobotId, model.ZoneId),
            TrafficRequestType.OUT => await TrafficACS.RequestOut(model.RobotId, model.ZoneId),
            _ => await TrafficACS.RequestOut(model.RobotId, model.ZoneId),
        };

    [HttpGet]
    public RobotACSLockedDto[] GetRobotLocked() => RobotManager.GetRobotACSLocked();
}
