using Core.Interfaces; using Core.Interfaces.Stock; using Domain.Entities; using Domain.Generics; using Models.Interfaces; using System.Reflection; namespace Core.Services.Stock { public class ProductDivisionService : IProductDivisionDom { #region Declaraciones y Constructor private readonly IPhLSMProductDivisionRepository _repository; public ProductDivisionService(IPhLSMProductDivisionRepository repository) { _repository = repository ?? throw new ArgumentNullException(nameof(repository)); } #endregion #region Métodos de clase public async Task> GetAllAsync(int page = 1, int pageSize = 50) { try { return await _repository.GetAllAsync(page, pageSize); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; throw new Exception($"{method} Message: {ex.Message}", ex); } } public async Task GetByIdAsync(int id) { try { return await _repository.GetByIdAsync(id); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; throw new Exception($"{method} Message: {ex.Message}", ex); } } public async Task> SearchAsync(string? term, int page = 1, int pageSize = 50) { try { return await _repository.SearchAsync(term, page, pageSize); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; throw new Exception($"{method} Message: {ex.Message}", ex); } } public async Task CreateAsync(EProductDivision entity) { try { return await _repository.CreateAsync(entity); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; throw new Exception($"{method} Message: {ex.Message}", ex); } } public async Task UpdateAsync(EProductDivision entity) { try { return await _repository.UpdateAsync(entity); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; throw new Exception($"{method} Message: {ex.Message}", ex); } } public async Task DeleteAsync(int id) { try { return await _repository.DeleteAsync(id); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; throw new Exception($"{method} Message: {ex.Message}", ex); } } #endregion } }