56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using AutoMapper;
|
|
using Azure;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Portfolio.Application.Services;
|
|
using Portfolio.Domain.Features.Dtos;
|
|
using Portfolio.Domain.Features.Pokemon;
|
|
using Portfolio.Domain.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Portfolio.Infrastructure.Repositories
|
|
{
|
|
public class PokemonRepository : IPokemonRepository
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
private readonly IBaseService _baseService;
|
|
private ResponseDto _response;
|
|
private IMapper _mapper;
|
|
|
|
public PokemonRepository(ApplicationDbContext context, IMapper mapper, IBaseService baseService)
|
|
{
|
|
_context = context;
|
|
_baseService = baseService;
|
|
_mapper = mapper;
|
|
_response = new ResponseDto();
|
|
|
|
}
|
|
|
|
|
|
public async Task<ResponseDto> GetAllPokemon()
|
|
{
|
|
return await _baseService.SendAsync(new RequestDto()
|
|
{
|
|
ApiType = StaticDetails.ApiType.GET,
|
|
Url = StaticDetails.PokemonSleepAPIBase + "/api/pokemon"
|
|
});
|
|
//try
|
|
//{
|
|
// IEnumerable<Pokemon> objList = _context.Pokemons.ToList();
|
|
// _response.IsSuccess = true;
|
|
// _response.Message = "All Pokemon found.";
|
|
// _response.Result = _mapper.Map<IEnumerable<PokemonDto>>(objList);
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// _response.IsSuccess = false;
|
|
// _response.Message = ex.Message;
|
|
//}
|
|
//return _response;
|
|
}
|
|
}
|
|
}
|