using LCU.API.Internal.Operations.IncentiveApiLib.Repositories; using LCU.Library.Internal.IncentiveApiModels.Entities; using LCU.Library.Internal.IncentiveApiModels.Enums; namespace LCU.API.Internal.Operations.IncentiveApi.Services; public class ProcessorHistoryService : IProcessorHistoryService { private readonly IProcessorHistoryRepository _processorHistoryRepository; private readonly IUnitOfWork _unitOfWork; public ProcessorHistoryService(IProcessorHistoryRepository processorHistoryRepository, IUnitOfWork unitOfWork) { _processorHistoryRepository = processorHistoryRepository; _unitOfWork = unitOfWork; } public async Task GetProcessorHistory(Process process) { try { return await _processorHistoryRepository.GetProcessorRunHistory(process); } catch (Exception) { Log.Error( $"Error in ProcessorHistoryService. GetProcessorRunHistory Failed to retrieve record for process: {process.ToString()}"); throw; } } public async Task SaveProcessorHistory(ProcessorHistoryRecord historyRecord) { try { var process = await _processorHistoryRepository.SaveProcessorRunHistory(historyRecord); await _unitOfWork.CompleteAsync(); return process; } catch (Exception) { Log.Error( $"Error in ProcessorHistoryService. SaveProcessorHistory Failed to retrieve record for process: {historyRecord.Process.ToString()}"); throw; } } }