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 GetRandomJoke() { var joke = JokesApi.GetJoke(); var jokeRepo = new JokesRepository(_connectionString); if (!jokeRepo.JokeExists(joke.OriginId)) { jokeRepo.AddJoke(joke); } return(jokeRepo.GetByOriginId(joke.OriginId)); }
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)); }
public IActionResult DislikeJoke(Joke joke) { var repo = new JokesRepository(_connectionString); var authDb = new Authentication(_connectionString); var user = authDb.GetByEmail(User.Identity.Name); if (repo.JokeInDb(joke.WebsiteId)) { joke.Id = repo.GetJokeId(joke.WebsiteId); repo.LikeDislikeJoke(joke.Id, user.Id, false); } else { repo.AddJoke(joke); joke.Id = repo.GetJokeId(joke.WebsiteId); repo.LikeDislikeJoke(joke.Id, user.Id, false); } return(Json("")); }
public string PostJoke(int pUserId, string pJoke) { IJokesRepository jokeRep = new JokesRepository(); return(jokeRep.AddJoke(pUserId, pJoke).ToString()); }
public void AddJoke() { JokesRepository repos = new JokesRepository(_connectionString); repos.AddJoke(); }