Files
prueba_tecnica_proxima/backend/ProximaContracts/ProximaContracts.Application/Rates/Services/RateService.cs
2025-06-15 18:29:25 +02:00

30 lines
938 B
C#

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);
}
}
}