This repository has been archived on 2025-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Pavel Vesely 5b3feaf26f Server naming fixes and cleanup
Server is now completely cleaned up and without warnings
2020-03-15 11:53:24 +01:00

51 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Oqtane.Models;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Oqtane.Infrastructure.Interfaces;
using Oqtane.Repository;
using Oqtane.Shared;
namespace Oqtane.Controllers
{
[Route("{site}/api/[controller]")]
public class LogController : Controller
{
private readonly ILogManager _logger;
private readonly ILogRepository _logs;
public LogController(ILogManager logger, ILogRepository logs)
{
_logger = logger;
_logs = logs;
}
// GET: api/<controller>?siteid=x&level=y&function=z&rows=50
[HttpGet]
[Authorize(Roles = Constants.AdminRole)]
public IEnumerable<Log> Get(string siteid, string level, string function, string rows)
{
return _logs.GetLogs(int.Parse(siteid), level, function, int.Parse(rows));
}
// GET api/<controller>/5
[HttpGet("{id}")]
[Authorize(Roles = Constants.AdminRole)]
public Log Get(int id)
{
return _logs.GetLog(id);
}
// POST api/<controller>
[HttpPost]
public void Post([FromBody] Log log)
{
if (ModelState.IsValid)
{
_logger.Log(log);
}
}
}
}