Example #1
0
        public async Task <ActionResult <PokemonDescriptionResponse> > GetPokemonDescriptionAsync(string pokemon_name)
        {
            var ret = new PokemonDescriptionResponse();

            ret.Name = pokemon_name;
            try
            {
                var desc = await _pokemonService.FindDescriptionByNameAsync(pokemon_name);

                if (desc is null)
                {
                    return(InternalError());
                }


                if (desc == string.Empty)
                {
                    _logger.LogWarning($"{pokemon_name}: not found");
                    return(NotFound());
                }


                ret.Description = await _shakespeareService.TranslateAsync(desc);

                if (string.IsNullOrEmpty(ret.Description))
                {
                    return(InternalError());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);

                throw;
            }
            return(Ok(ret));
        }