using Core.Interfaces;
using Domain.Entities;
using Models.Interfaces;
using System.Reflection;

namespace Core.Services
{
    public class TaxConditionService : ITaxConditionDom
    {
    #region Declaraciones y Constructor
        private readonly IPhSTaxConditionRepository _repository;
        public TaxConditionService(IPhSTaxConditionRepository repository)
        {
            _repository = repository ?? throw new ArgumentNullException(nameof(repository));
        }
    #endregion
    #region Metodos de clase
        public async Task<IEnumerable<ETaxCondition>> GetAllAsync()
        {
            try
            {
                return await _repository.GetAllAsync();
            }
            catch (Exception ex)
            {
                var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
                throw new Exception($"{methodName} Message: {ex.Message}", ex);
            }
        }
        public async Task<ETaxCondition?> GetByNameAsync(string name)
        {
            try
            {
                return await _repository.GetByNameAsync(name);
            }
            catch (Exception ex)
            {
                var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
                throw new Exception($"{methodName} Message: {ex.Message}", ex);
            }
        }
    #endregion
    }
}