Exemplo n.º 1
0
        //Delete Types
        public async Task DeleteTypes(Types typesToDelete)
        {
            var response = await client.DeleteAsync($"/api/types/{typesToDelete.ID}");

            if (!response.IsSuccessStatusCode)
            {
                var ex = ProfessorOak.CreateApiException(response);
                throw ex;
            }
        }
Exemplo n.º 2
0
        //Add Types
        public async Task AddTypes(Types typesToAdd)
        {
            var response = await client.PostAsJsonAsync("/api/types", typesToAdd);

            if (!response.IsSuccessStatusCode)
            {
                var ex = ProfessorOak.CreateApiException(response);
                throw ex;
            }
        }
        //Delete Pokemon
        public async Task DeletePokemon(Pokemon pokemonToDelete)
        {
            var response = await client.DeleteAsync($"/api/pokemons/{pokemonToDelete.ID}");

            if (!response.IsSuccessStatusCode)
            {
                var ex = ProfessorOak.CreateApiException(response);
                throw ex;
            }
        }
        //Update Region
        public async Task UpdateRegion(Region regionToUpdate)
        {
            var response = await client.PutAsJsonAsync($"/api/regions/{regionToUpdate.ID}", regionToUpdate);

            if (!response.IsSuccessStatusCode)
            {
                var ex = ProfessorOak.CreateApiException(response);
                throw ex;
            }
        }
        //Add Pokemon
        public async Task AddPokemon(Pokemon pokemonToAdd)
        {
            var response = await client.PostAsJsonAsync("/api/pokemons", pokemonToAdd);

            if (!response.IsSuccessStatusCode)
            {
                var ex = ProfessorOak.CreateApiException(response);
                throw ex;
            }
        }