using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NetworkResurrector.Server.Application.Queries;
using System;
using System.Threading.Tasks;

namespace NetworkResurrector.Server.Controllers
{
    [Authorize]
    [ApiController]
    [Route("system")]
    public class SystemController : ControllerBase
    {
        private readonly IMediator _mediator;

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

        [AllowAnonymous]
        [HttpGet("ping")]
        public IActionResult Ping()
        {
            return Ok($"Ping success. System datetime: {DateTime.Now}");
        }

        [HttpGet("version")]
        public async Task<IActionResult> GetSystemVersion([FromRoute] GetSystemVersion.Query query)
        {
            var result = await _mediator.Send(query);
            return Ok(result);
        }
    }
}
