101 lines
3.0 KiB
C#
101 lines
3.0 KiB
C#
using Newtonsoft.Json;
|
|
using Portfolio.Domain.Features.Articles;
|
|
using Portfolio.Domain.Features.Dtos;
|
|
using Portfolio.Domain.Features.Pokemon;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Portfolio.Application.Services.PokemonService
|
|
{
|
|
public class PokemonService : IPokemonService
|
|
{
|
|
private readonly IPokemonRepository _pokemonRepository;
|
|
|
|
public PokemonService(IPokemonRepository pokemonRepository)
|
|
{
|
|
_pokemonRepository = pokemonRepository;
|
|
}
|
|
public async Task<List<PokemonDto>> GetAllPokemonAsync()
|
|
{
|
|
List<PokemonDto> pokemons = new List<PokemonDto>();
|
|
ResponseDto? response = await _pokemonRepository.GetAllPokemon();
|
|
|
|
if (response != null && response.IsSuccess)
|
|
{
|
|
pokemons = JsonConvert.DeserializeObject<List<PokemonDto>>(Convert.ToString(response.Result));
|
|
}
|
|
|
|
return pokemons;
|
|
|
|
|
|
//return new List<Pokemon>() {
|
|
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 1,
|
|
// PokemonName = "Bulbasaur",
|
|
// SleepType = "Dozing",
|
|
// Speciality = "Ingredients"
|
|
|
|
// },
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 2,
|
|
// PokemonName = "Ivysaur",
|
|
// SleepType = "Dozing",
|
|
// Speciality = "Ingredients"
|
|
|
|
// },
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 3,
|
|
// PokemonName = "Venasaur",
|
|
// SleepType = "Dozing",
|
|
// Speciality = "Ingredients"
|
|
|
|
// },
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 37,
|
|
// PokemonName = "Vulpix",
|
|
// SleepType = "Snoozing",
|
|
// Speciality = "Berries"
|
|
|
|
// },
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 38,
|
|
// PokemonName = "Ninetails",
|
|
// SleepType = "Snoozing",
|
|
// Speciality = "Berries"
|
|
|
|
// },
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 37,
|
|
// PokemonName = "Vulpix",
|
|
// IsVariation = true,
|
|
// VariationName = "Alolan",
|
|
// SleepType = "Slumbering",
|
|
// Speciality = "Berries"
|
|
|
|
// },
|
|
// new Pokemon
|
|
// {
|
|
// PokemonId = 38,
|
|
// PokemonName = "Ninetails",
|
|
// IsVariation = true,
|
|
// VariationName = "Alolan",
|
|
// SleepType = "Slumbering",
|
|
// Speciality = "Berries"
|
|
|
|
// },
|
|
//};
|
|
}
|
|
}
|
|
}
|