phronCare/Core/Services/Stock/ProductDivisionService.cs
Leandro Hernan Rojas 85fedf79af
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 7m45s
Add Stock Module MVP Divisiones
2025-06-27 13:52:22 -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 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<PagedResult<EProductDivision>> 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<EProductDivision?> 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<EProductDivision>> 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<EProductDivision> 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<bool> 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<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
}
}