public Joke GetRandomJoke()
        {
            var joke     = JokesApi.GetJoke();
            var jokeRepo = new JokesRepository(_connectionString);

            if (!jokeRepo.JokeExists(joke.OriginId))
            {
                jokeRepo.AddJoke(joke);
            }

            return(jokeRepo.GetByOriginId(joke.OriginId));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var joke     = JokesApi.GetJoke();
            var jokeRepo = new JokesRepository(_connectionString);

            if (!jokeRepo.JokeExists(joke.OriginId))
            {
                jokeRepo.AddJoke(joke);
            }
            else
            {
                joke = jokeRepo.GetByOriginId(joke.OriginId);
            }
            var viewModel = new IndexViewModel {
                Joke = joke
            };

            viewModel.InteractionStatus = GetStatus(joke.Id);
            return(View(viewModel));
        }