Files
monorepo/LCU.API.Internal.MaidBotApi/LCU.Api.Internal.MaidBotLib/Repositories/LoggingMatrixRepository.cs
T
2026-03-11 13:21:47 -05:00

60 lines
2.3 KiB
C#

using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Api.Internal.MaidBotLib.Persistence;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public class LoggingMatrixRepository : BaseRepository, ILoggingMatrixRepository
{
public LoggingMatrixRepository(AppDbContext context) : base(context) { }
public async Task<IEnumerable<LoggingMatrix>> ListAsync()
{
return await _context.LoggingMatrixs.ToListAsync();
}
public async Task<IEnumerable<LoggingMatrix>> ListActiveAsync()
{
return await _context.LoggingMatrixs.Where(loggingMatrix => !loggingMatrix.Disabled).ToListAsync();
}
public async Task<LoggingMatrix> FindByIdAsync(int id)
{
return await _context.LoggingMatrixs.Where(loggingMatrix => loggingMatrix.LoggingMatrixId == id).FirstOrDefaultAsync();
}
public async Task<IEnumerable<LoggingMatrix>> RetrieveByApplicationLevelAndGroup(string application, string level, string group)
{
return await _context.LoggingMatrixs
.Where(matrix => matrix.Application == application &&
matrix.Level == level &&
matrix.Group == group &&
!matrix.Disabled)
.ToListAsync();
}
public async Task<IEnumerable<LoggingMatrix>> RetrieveByApplciationAndLevel(string application, string level)
{
return await _context.LoggingMatrixs
.Where(matrix => matrix.Application == application &&
matrix.Level == level &&
!matrix.Disabled)
.ToListAsync();
}
public async Task<LoggingMatrix> AddAsync(LoggingMatrix loggingMatrix)
{
var result = await _context.LoggingMatrixs.AddAsync(loggingMatrix);
return result.Entity;
}
public void Update(LoggingMatrix loggingMatrix)
{
_context.LoggingMatrixs.Update(loggingMatrix);
}
}
}