using Indotalent.Data.Entities;
using Indotalent.Infrastructure.Database;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using Microsoft.EntityFrameworkCore;

namespace Indotalent.Features.Serilogs;

[Route("odata/SerilogLogs")]
public class SerilogsODataController : ODataController
{
    private readonly AppDbContext _context;

    public SerilogsODataController(AppDbContext context)
    {
        _context = context;
    }

    [EnableQuery]
    [HttpGet]
    public IQueryable<SerilogLogs> Get()
    {
        return _context.Set<SerilogLogs>()
            .OrderByDescending(x => x.TimeStamp)
            .AsNoTracking();
    }

}