public Joke GetRandomJoke() { var joke = JokeApi.GetJoke(); var jokesRepo = new JokesRepository(_connectionString); if (jokesRepo.NewJoke(joke.Number)) { jokesRepo.AddJoke(joke); } return(jokesRepo.GetByNumber(joke.Number)); }
public Joke GetJoke() { var joke = JokeApi.GetJoke(); var repo2 = new UserRepository(_connectionString); var user = repo2.GetByEmail(User.Identity.Name); var repo = new JokeRepository(_connectionString); var wasliked = repo.UserLikedJoke(joke.Id, user.Id); if (!wasliked) { return(joke); } return(repo.GetJokeWithLikes(joke.Id)); }