phronCare/Core/Services/Stock/LSProductDivisionService.cs
Leandro Hernan Rojas 1be33c37b5
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 16m35s
Add Products
2025-06-30 16:15:08 -03:00

101 lines
3.2 KiB
C#

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 LSProductDivisionService : ILSProductDivisionDom
{
#region Declaraciones y Constructor
private readonly IPhLSMProductDivisionRepository _repository;
public LSProductDivisionService(IPhLSMProductDivisionRepository repository)
{
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
}
#endregion
#region Métodos de clase
public async Task<PagedResult<ELSProductDivision>> 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<ELSProductDivision?> 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<PagedResult<ELSProductDivision>> 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<ELSProductDivision> CreateAsync(ELSProductDivision 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<bool> UpdateAsync(ELSProductDivision 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<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
}
}