Exemplo n.º 1
0
 public IActionResult Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         var  repo = new JokesRepository(_conn);
         User user = repo.GetUserByEmail(User.Identity.Name);
         Joke joke = repo.GenerateRandomJoke();
         var  vm   = new RandomJokeViewModel
         {
             Joke     = joke,
             User     = user,
             Liked    = repo.DidUserLike(user.Id, joke.Id),
             Disliked = repo.DidUserDislike(user.Id, joke.Id)
         };
         return(View(vm));
     }
     else
     {
         return(Redirect("/account/login"));
     }
 }