PokemonSleepTools/PokemonSleep.Web/Service/PokemonService.cs

53 lines
1.6 KiB
C#

using PokemonSleep.Web.Models;
using PokemonSleep.Web.Service.IService;
using PokemonSleep.Web.Utility;
namespace PokemonSleep.Web.Service
{
public class PokemonService : IPokemonService
{
private readonly IBaseService _baseService;
public PokemonService(IBaseService baseService)
{
_baseService = baseService;
}
public async Task<ResponseDto?> CreatePokemonAsync(PokemonDto pokemonDto)
{
return await _baseService.SendAsync(new RequestDto()
{
ApiType = StaticDetails.ApiType.POST,
Data = pokemonDto,
Url = StaticDetails.PokemonSleepAPIBase + "/api/pokemon"
});
}
public async Task<ResponseDto?> DeletePokemonAsync(int id)
{
return await _baseService.SendAsync(new RequestDto()
{
ApiType = StaticDetails.ApiType.DELETE,
Url = StaticDetails.PokemonSleepAPIBase + "/api/pokemon/" + id
});
}
public async Task<ResponseDto?> GetAllPokemonAsync()
{
return await _baseService.SendAsync(new RequestDto()
{
ApiType = StaticDetails.ApiType.GET,
Url = StaticDetails.PokemonSleepAPIBase + "/api/pokemon"
});
}
public async Task<ResponseDto?> GetPokemonByIdAsync(int id)
{
return await _baseService.SendAsync(new RequestDto()
{
ApiType = StaticDetails.ApiType.GET,
Url = StaticDetails.PokemonSleepAPIBase + "/api/pokemon/" + id
});
}
}
}