Пример #1
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(""));
        }
Пример #2
0
        public void LikeDislikeJoke(LikeDislikeViewModel vm)
        {
            var ulj = new UserLikedJoke
            {
                UserId = GetCurrentUser().Id,
                JokeId = vm.JokeId,
                Liked  = vm.Like,
                Date   = DateTime.Now
            };

            var jokesRepo = new JokesRepository(_connectionString);

            jokesRepo.LikeDislikeJoke(ulj);
        }