using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using PokemonSleep.Web.Models; using PokemonSleep.Web.Service.IService; namespace PokemonSleep.Web.Controllers { public class PokemonController : Controller { private readonly IPokemonService _pokemonService; private readonly IPokemonNatureService _natureService; private readonly IPokemonSubskillService _subskillService; public PokemonController(IPokemonService pokemonService, IPokemonNatureService natureService, IPokemonSubskillService subskillService) { _pokemonService = pokemonService; _natureService = natureService; _subskillService = subskillService; } public async Task PokemonIndex() { PokemonSleepDto? list = new(); ResponseDto? presponse = await _pokemonService.GetAllPokemonAsync(); ResponseDto? nresponse = await _natureService.GetAllPokemonNaturesAsync(); ResponseDto? sresponse = await _subskillService.GetAllPokemonSubskillsAsync(); if (presponse != null && presponse.IsSuccess) { list.pokemonList = JsonConvert.DeserializeObject>(Convert.ToString(presponse.Result)); } if (nresponse != null && nresponse.IsSuccess) { list.natureList = JsonConvert.DeserializeObject>(Convert.ToString(nresponse.Result)); } if (sresponse != null && sresponse.IsSuccess) { list.subskillList = JsonConvert.DeserializeObject>(Convert.ToString(sresponse.Result)); } return View(list); } } }