2025-06-27 13:52:22 -03:00
|
|
|
|
using Core.Interfaces;
|
|
|
|
|
|
using Core.Interfaces.Stock;
|
|
|
|
|
|
using Domain.Entities;
|
|
|
|
|
|
using Domain.Generics;
|
|
|
|
|
|
using Models.Interfaces;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Core.Services.Stock
|
|
|
|
|
|
{
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public class LSProductDivisionService : ILSProductDivisionDom
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
#region Declaraciones y Constructor
|
|
|
|
|
|
private readonly IPhLSMProductDivisionRepository _repository;
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public LSProductDivisionService(IPhLSMProductDivisionRepository repository)
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Métodos de clase
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public async Task<PagedResult<ELSProductDivision>> GetAllAsync(int page = 1, int pageSize = 50)
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return await _repository.GetAllAsync(page, pageSize);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
|
|
|
|
|
|
throw new Exception($"{method} Message: {ex.Message}", ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public async Task<ELSProductDivision?> GetByIdAsync(int id)
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return await _repository.GetByIdAsync(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
|
|
|
|
|
|
throw new Exception($"{method} Message: {ex.Message}", ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public async Task<PagedResult<ELSProductDivision>> SearchAsync(string? term, int page = 1, int pageSize = 50)
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public async Task<ELSProductDivision> CreateAsync(ELSProductDivision entity)
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return await _repository.CreateAsync(entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
var method = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
|
|
|
|
|
|
throw new Exception($"{method} Message: {ex.Message}", ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-30 16:15:08 -03:00
|
|
|
|
public async Task<bool> UpdateAsync(ELSProductDivision entity)
|
2025-06-27 13:52:22 -03:00
|
|
|
|
{
|
|
|
|
|
|
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<bool> 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
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|