public IActionResult Index() { var repo = new JokesRepository(_connectionString); IndexViewModel vm = new IndexViewModel(); vm.Joke = repo.GetRandomJoke(); if (User.Identity.IsAuthenticated) { var usersRepo = new UsersRepository(_connectionString); vm.User = usersRepo.GetByEmail(User.Identity.Name); } return(View(vm)); }
public Joke GetRandomJoke() { var repo = new JokesRepository(_connectionString); return(repo.GetRandomJoke()); }