Пример #1
0
        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));
        }
Пример #2
0
        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();
        }