Adding MaidBotApi
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using LCU.Api.Internal.MaidBotApi.Exceptions;
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Api.Internal.MaidBotLib.Repositories;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
|
||||
namespace LCU.Api.Internal.MaidBotApi.Services;
|
||||
|
||||
public class DebugEventLogService : IDebugEventLogService
|
||||
{
|
||||
private readonly IDebugEventLogRepository _debugEventLogRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public DebugEventLogService(IUnitOfWork unitOfWork,
|
||||
IDebugEventLogRepository debugEventLogRepository)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_debugEventLogRepository = debugEventLogRepository;
|
||||
}
|
||||
|
||||
public async Task DebugEventLog(EventLog eventLog)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(eventLog.DebugData))
|
||||
{
|
||||
var debugEventLog = new DebugEventLog(eventLog);
|
||||
await SaveAsync(debugEventLog);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<DebugEventLog> SaveAsync(DebugEventLog debugEventLog)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _debugEventLogRepository.AddAsync(debugEventLog);
|
||||
await _unitOfWork.CompleteAsync();
|
||||
return result;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure saving DebugEventLog.");
|
||||
throw new ServiceException($"Failure saving DebugEventLog.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user