Exemplo n.º 1
0
        public IActionResult Jokes()
        {
            var repo    = new JokesRepository(_conn);
            var jokesVm = new List <JokeViewModel>();
            var jokes   = repo.GetJokes();

            foreach (Joke j in jokes)
            {
                jokesVm.Add(new JokeViewModel
                {
                    Joke     = j,
                    Likes    = repo.GetLikesByJokeId(j.Id),
                    Dislikes = repo.GetDislikesByJokeId(j.Id),
                });
            }
            return(View(jokesVm));
        }