コード例 #1
0
        public async Task insertCommentLike(Comment_Like comment_Like)
        {
            var commment_like_collection = dataContext.getConnection().GetCollection <Comment_Like>("Comment_Like");
            await commment_like_collection.InsertOneAsync(comment_Like);

            Debug.WriteLine("Inserted comment like: " + comment_Like.comment_id);
        }
コード例 #2
0
        public IActionResult Like_Comment(int num)
        {
            // if(HttpContext.Session.GetInt32("id") == null) {
            //     return RedirectToAction("Logout");};

            Comment it   = _context.comments.Include(g => g.Comment_Likes).ThenInclude(a => a.Liked_Comment).SingleOrDefault(u => u.Commentid == num);
            User    user = _context.users.SingleOrDefault(u => u.Userid == HttpContext.Session.GetInt32("id"));

            Comment_Like newl = new Comment_Like {
                Userid            = user.Userid,
                Liked_Comment     = user,
                Commentid         = it.Commentid,
                Has_Comment_Likes = it
            };

            it.Comment_Likes.Add(newl);
            _context.SaveChanges();
            return(RedirectToAction("Wall"));
        }