using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NetworkResurrector.Agent.PublishedLanguage.Commands;
using System.Threading.Tasks;

namespace NetworkResurrector.Agent.Controllers
{
    [ApiController]
    [Authorize]
    [Route("host")]
    public class HostController : ControllerBase
    {
        private readonly IMediator _mediator;

        public HostController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpPost("shutdown")]
        public async Task<IActionResult> Shutdown([FromBody] Shutdown shutdown)
        {
            var result = await _mediator.Send(shutdown);
            return Ok(result);
        }

        [HttpPost("restart")]
        public async Task<IActionResult> Restart([FromBody] Restart restart)
        {
            var result = await _mediator.Send(restart);
            return Ok(result);
        }

        [HttpPost("sleep")]
        public async Task<IActionResult> Sleep([FromBody] Sleep sleep)
        {
            var result = await _mediator.Send(sleep);
            return Ok(result);
        }

        [HttpPost("logout")]
        public async Task<IActionResult> Logout([FromBody] Logout logout)
        {
            var result = await _mediator.Send(logout);
            return Ok(result);
        }

        [HttpPost("lock")]
        public async Task<IActionResult> Lock([FromBody] Lock _lock)
        {
            var result = await _mediator.Send(_lock);
            return Ok(result);
        }

        [HttpPost("cancel")]
        public async Task<IActionResult> Cancel([FromBody] Cancel cancel)
        {
            var result = await _mediator.Send(cancel);
            return Ok(result);
        }
    }
}
