public async Task <ServiceResponse <GetPokemonDto> > Handle(PokemonDeleteCommand request, CancellationToken cancellationToken) { ServiceResponse <GetPokemonDto> serviceResponse = new ServiceResponse <GetPokemonDto>(); try { var pokemonDto = await _pokemonRepository.GetPokemon(EnumPokemonSelectOptions.Number, request.Number.ToString()); if (String.IsNullOrEmpty(pokemonDto.Name)) { throw new ArgumentException(); } await _pokemonRepository.DeletePokemon(request.Number); serviceResponse.Message = $"Pokemon: {pokemonDto.Name}, has been removed."; } catch (Exception e) { serviceResponse.Success = false; serviceResponse.Message = "Sorry, we can't find any info about that pokemon."; } return(serviceResponse); }
public async Task <IActionResult> DeletePokemonByNumber([FromRoute] PokemonDeleteCommand command) { var serviceResponse = await _mediator.Send(command); return(Ok(serviceResponse)); }