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));
        }
示例#3
0
        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));
        }
示例#4
0
        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(""));
        }
示例#5
0
        public string PostJoke(int pUserId, string pJoke)
        {
            IJokesRepository jokeRep = new JokesRepository();

            return(jokeRep.AddJoke(pUserId, pJoke).ToString());
        }
示例#6
0
        public void AddJoke()
        {
            JokesRepository repos = new JokesRepository(_connectionString);

            repos.AddJoke();
        }