Пример #1
0
        public void Like(int userId, int jokeId)
        {
            var repo = new JokesRepository(_conn);

            repo.LikeJoke(userId, jokeId);
            //return Redirect("/home/jokes");
        }
Пример #2
0
        public void LikeJoke(UserLikedJokes ulj)
        {
            var repo  = new JokesRepository(_connectionString);
            var repo2 = new UserRepository(_connectionString);

            ulj.UserId = repo2.GetByEmail(User.FindFirst("user")?.Value).Id;
            ulj.Date   = DateTime.Now;
            repo.LikeJoke(ulj);
        }
Пример #3
0
        public IActionResult LikeJoke(int jokeId, bool like)
        {
            if (User.Identity.Name == null)
            {
                return(Json(new { result = "Redirect", url = Url.Action("Login", "Account") }));
            }
            JokesRepository rep = new JokesRepository(_connString);

            rep.LikeJoke(jokeId, User.Identity.Name, like);
            return(Json("done"));
        }