public async Task <SavePokemonResponse> UpdateAsync(int id, Pokemon pokemon) { var existingRepository = await _pokemonRepository.FindByIdAsync(id); if (existingRepository == null) { return(new SavePokemonResponse("Pokemon nao encontrado")); } existingRepository.Name_Custom = pokemon.Name_Custom; existingRepository.Nivel = pokemon.Nivel; existingRepository.Id_Trainer = pokemon.Id_Trainer; existingRepository.Id_Pokedex = pokemon.Id_Pokedex; try { _pokemonRepository.Update(existingRepository); await _unitOfWork.CompleteAsync(); return(new SavePokemonResponse(existingRepository)); } catch (Exception ex) { return(new SavePokemonResponse($"Um erro ocorreu ao atualizar o pokemon: {ex.Message}")); } }
public async Task <SavePokemonResponse> GetById(Guid id) { var existingRepository = await _pokemonRepository.FindByIdAsync(id); if (existingRepository == null) { return(new SavePokemonResponse("Pokemon nao encontrado")); } return(new SavePokemonResponse(existingRepository)); }