using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Watcher.Data;

[Route("[controller]/v1")]
public class ApiController : Controller
{
    private readonly AppDbContext _context;
    private readonly ILogger<ApiController> _logger;


    public ApiController(AppDbContext context, ILogger<ApiController> logger)
    {
        _context = context;
        _logger = logger;
    }

    [HttpGet("reference")]
    public IActionResult ApiReference()
    {
        return View();
    }

    [HttpGet("servers")]
    public async Task<IActionResult> GetAllServers()
    {
        var Servers = await _context.Servers.OrderBy(s => s.Id).ToListAsync();
        return Ok(Servers);
    }
}