示例#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);
        }
        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"));
        }