30 lines
938 B
C#
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);
|
|
}
|
|
|
|
}
|
|
}
|