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

namespace Core.Services
{
    public class AccountTypeService : IAccountTypeDom
    {
    #region Declaraciones y Constructor
        private readonly IPhSAccountTypeRepository _repository;
        public AccountTypeService(IPhSAccountTypeRepository repository)
        {
            _repository = repository ?? throw new ArgumentNullException(nameof(repository));
        }
    #endregion
    #region Metodos de clase
        public async Task<IEnumerable<EAccountType>> 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<EAccountType?> 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
    }
}
