Adding MaidBotApi

This commit is contained in:
Zeeshaun
2026-03-11 13:21:47 -05:00
parent f3cb730f3b
commit f004c8205a
122 changed files with 4227 additions and 0 deletions
@@ -0,0 +1,17 @@
using LCU.Api.Internal.MaidBotLib.Persistence;
using System;
using System.Collections.Generic;
using System.Text;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public abstract class BaseRepository
{
protected readonly AppDbContext _context;
public BaseRepository(AppDbContext context)
{
_context = context;
}
}
}
@@ -0,0 +1,20 @@
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 DebugEventLogRepository : BaseRepository, IDebugEventLogRepository
{
public DebugEventLogRepository(AppDbContext context) : base(context) { }
public async Task<DebugEventLog> AddAsync(DebugEventLog debugEventLog)
{
var result = await _context.DebugEventLogs.AddAsync(debugEventLog);
return result.Entity;
}
}
}
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Api.Internal.MaidBotLib.Persistence;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public class EventLogRepository : BaseRepository, IEventLogRepository
{
public EventLogRepository(AppDbContext context) : base(context) { }
public async Task<IEnumerable<EventLog>> ListAsync()
{
return await _context.EventLogs.ToListAsync();
}
public async Task<EventLog> AddAsync(EventLog eventLog)
{
var result = await _context.EventLogs.AddAsync(eventLog);
return result.Entity;
}
public void RemoveRange(List<EventLog> eventLog)
{
_context.EventLogs.RemoveRange(eventLog);
}
}
}
@@ -0,0 +1,13 @@
using LCU.Api.Internal.MaidBotLib.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public interface IDebugEventLogRepository
{
Task<DebugEventLog> AddAsync(DebugEventLog debugEventLog);
}
}
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Api.Internal.MaidBotLib.Models;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public interface IEventLogRepository
{
Task<IEnumerable<EventLog>> ListAsync();
Task<EventLog> AddAsync(EventLog eventLog);
void RemoveRange(List<EventLog> eventLog);
}
}
@@ -0,0 +1,19 @@
using LCU.Api.Internal.MaidBotLib.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public interface ILoggingMatrixRepository
{
Task<IEnumerable<LoggingMatrix>> ListAsync();
Task<IEnumerable<LoggingMatrix>> ListActiveAsync();
Task<LoggingMatrix> FindByIdAsync(int id);
Task<IEnumerable<LoggingMatrix>> RetrieveByApplicationLevelAndGroup(string application, string level, string group);
Task<IEnumerable<LoggingMatrix>> RetrieveByApplciationAndLevel(string application, string level);
Task<LoggingMatrix> AddAsync(LoggingMatrix loggingMatrix);
void Update(LoggingMatrix loggingMatrix);
}
}
@@ -0,0 +1,10 @@
using System.Threading.Tasks;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public interface IUnitOfWork
{
Task CompleteAsync();
void Complete();
}
}
@@ -0,0 +1,59 @@
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);
}
}
}
@@ -0,0 +1,25 @@
using LCU.Api.Internal.MaidBotLib.Persistence;
using System.Threading.Tasks;
namespace LCU.Api.Internal.MaidBotLib.Repositories
{
public class UnitOfWork : IUnitOfWork
{
private readonly AppDbContext _context;
public UnitOfWork(AppDbContext context)
{
_context = context;
}
public async Task CompleteAsync()
{
await _context.SaveChangesAsync();
}
public void Complete()
{
_context.SaveChanges();
}
}
}