add basic logging ui (#14)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace ErsatzTV.Infrastructure.Data.Configurations
|
||||
{
|
||||
public class LogEntryConfiguration : IEntityTypeConfiguration<LogEntry>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<LogEntry> builder) =>
|
||||
builder.ToTable("Logs");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ErsatzTV.Infrastructure.Data
|
||||
{
|
||||
public class LogContext : DbContext
|
||||
{
|
||||
public LogContext(DbContextOptions<LogContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<LogEntry> LogEntries { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
builder.ApplyConfigurationsFromAssembly(typeof(LogContext).Assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Interfaces.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
{
|
||||
public class LogRepository : ILogRepository
|
||||
{
|
||||
private readonly LogContext _logContext;
|
||||
|
||||
public LogRepository(LogContext logContext) => _logContext = logContext;
|
||||
|
||||
public Task<List<LogEntry>> GetRecentLogEntries() =>
|
||||
_logContext.LogEntries.OrderByDescending(e => e.Id).Take(100).ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user