prueba tecnica
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using AutoMapper;
|
||||
using ProximaContracts.Domain.Rates.DTOs.Responses;
|
||||
using ProximaContracts.Infrastructure.Rpositories.Rates;
|
||||
using ProximaContracts.Shared.Exceptions.Repositories.Rates;
|
||||
|
||||
namespace ProximaContracts.Application.Rates.Services
|
||||
{
|
||||
public class RateService(IRateRepository repository, IMapper mapper) : IRateService
|
||||
{
|
||||
private readonly IRateRepository _repository = repository;
|
||||
private readonly IMapper _mapper = mapper;
|
||||
|
||||
public async Task<bool> CheckIfExists(int id)
|
||||
{
|
||||
return await _repository.CheckIfExists(id);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GetAllRatesDto>> GetRates()
|
||||
{
|
||||
var response = await _repository.GetRates();
|
||||
if (!response.Any())
|
||||
{
|
||||
throw new GetAllRates404Exception("No Rates found");
|
||||
}
|
||||
return _mapper.Map<List<GetAllRatesDto>>(response);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user