Files
2026-03-24 15:26:03 -05:00

55 lines
1.9 KiB
C#

using System.Collections.Generic;
using Microsoft.Data.SqlClient;
using LCU.Api.Internal.DispatcherLib.Repositories;
namespace LCU.Api.Internal.Dispatcher.Services;
public class JobErrorRecipientService : IJobErrorRecipientService
{
private readonly IUnitOfWork _unitOfWork;
private readonly IJobErrorRecipientRepository _jobErrorRecipientRepository;
public JobErrorRecipientService(IUnitOfWork unitOfWork,
IJobErrorRecipientRepository jobErrorRecipientRepository)
{
_unitOfWork = unitOfWork;
_jobErrorRecipientRepository = jobErrorRecipientRepository;
}
public void SaveList(ICollection<JobErrorRecipient> jobErrorRecipient)
{
try
{
_jobErrorRecipientRepository.AddList(jobErrorRecipient);
_unitOfWork.Complete();
}
catch (SqlException ex)
{
Log.Error(ex, $"SQL Failure saving list of job error recipients.");
throw new ServiceException($"SQL Failure saving list of job error recipients.");
}
catch (Exception ex)
{
Log.Error(ex, $"Failure saving list of job error recipients.");
throw new ServiceException($"Failure saving list of job error recipients.");
}
}
public void DeleteList(ICollection<JobErrorRecipient> jobErrorRecipient)
{
try
{
_jobErrorRecipientRepository.RemoveList(jobErrorRecipient);
_unitOfWork.Complete();
}
catch (SqlException ex)
{
Log.Error(ex, $"SQL Failure removing list of job error recipients.");
throw new ServiceException($"SQL Failure removing list of job error recipients.");
}
catch (Exception ex)
{
Log.Error(ex, $"Failure removing list of job error recipients.");
throw new ServiceException($"Failure removing list of job error recipients.");
}
}
}