phronCare/Core/Services/CustomerService.cs
Leandro Hernan Rojas 650650b9a6
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 3m7s
Add Pagination on GetAll Customer in API
2025-04-06 01:35:31 -03:00

71 lines
2.0 KiB
C#

using System.Reflection;
using Core.Interfaces;
using Domain.Entities;
using Domain.Generics;
using Models.Helpers;
using Models.Interfaces;
using Models.Models;
namespace Core.Services
{
public class CustomerService: ICustomerDom
{
#region Declaraciones y Constructor
private readonly IPhSCustomerRepository _repository;
public CustomerService(IPhSCustomerRepository customerRepository)
{
_repository = customerRepository ?? throw new ArgumentNullException(nameof(customerRepository));
}
#endregion
public Task<ECustomer> AddAsync(ECustomer entity)
{
throw new NotImplementedException();
}
public Task<bool> DeleteAsync(int id)
{
throw new NotImplementedException();
}
public async Task<PagedResult<ECustomer>> GetAllAsync(int page = 1, int pageSize = 50)
{
try
{
return await _repository.GetAllAsync(page, pageSize);
}
catch (Exception ex)
{
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
throw new Exception($"{methodName} Message: {ex.Message}", ex);
}
}
public Task<ECustomer?> GetByIdAsync(int id)
{
throw new NotImplementedException();
}
public async Task<PagedResult<ECustomer>> SearchAsync(string? name, string? email, string? document, int page, int pageSize)
{
try
{
return await _repository.SearchAsync(name, email, document, page, pageSize);
}
catch (Exception ex)
{
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
throw new Exception($"{methodName} Message: {ex.Message}", ex);
}
}
public Task<bool> UpdateAsync(ECustomer entity)
{
throw new NotImplementedException();
}
}
}